gpt4 book ai didi

rebol - block 的唯一性不会删除重复项

转载 作者:行者123 更新时间:2023-12-01 12:33:15 28 4
gpt4 key购买 nike

字符串是 url 的一部分,我去掉了它的基数。parse 检测到一些 html 文件中的四个 url。我已将问题缩小为:

REBOL []
images: [{,W,H,wi,1TV1Rvu8EF9FDdUxKy+hTKK/RNifw3WQDJEI/sYkX78tyNifGd0/U4RpaBox1rO448B4dv24sYoTgxOMVC7Lz5J9sJXlk0nkM89n55HzX7qbRiX/cSkd3lepAEIj3LVTN7gmQLCI2+INwwg18IyDklZ3VZWkw011+77dkfgTTRlRaY397ricx4dk4BTHvCLZ} {,W,H,wi,1TV1Rvu8EF9FDdUxKy+hTKK/RNifw3WQDJEI/sYkX78tyNifGd0/U4RpaBox1rO448B4dv24sYoTgxOMVC7Lz5J9sJXlk0nkM89n55HzX7qbRiX/cSkd3lepAEIj3LVTN7gmQLCI2+INwwg18IyDklZ3VZWkw011+77dkfgTTRlRaY397ricx4dk4BTHvCLZ} {,W,H,wi,1TV1Rvu8EF9FDdUxKy+hTKK/RNifw3WQDJEI/sYkX78wvYn3cKtEeN/9Y8EfNR8J48B4dv24sYoTgxOMVC7Lz5J9sJXlk0nkM89n55HzX7qbRiX/cSkd3lepAEIj3LVTN7gmQLCI2+INwwg18IyDklZ3VZWkw011+77dkfgTTRlRaY397ricx4dk4BTHvCLZ} {,W,H,wi,1TV1Rvu8EF9FDdUxKy+hTKK/RNifw3WQDJEI/sYkX78wvYn3cKtEeN/9Y8EfNR8J48B4dv24sYoTgxOMVC7Lz5J9sJXlk0nkM89n55HzX7qbRiX/cSkd3lepAEIj3LVTN7gmQLCI2+INwwg18IyDklZ3VZWkw011+77dkfgTTRlRaY397ricx4dk4BTHvCLZ}]

print join "before: " length? images
unique images
print join "after: " length? images

print join "1=2? " images/1 = images/2
print join "1=3? " images/1 = images/3
print join "1=4? " images/1 = images/4
print join "2=3? " images/2 = images/3
print join "2=4? " images/2 = images/4
print join "3=4? " images/3 = images/4

可以看出,url 1 和 2 是相同的,url 3 和 4 也可以说是相同的。不过,unique 不会删除重复项。为什么会出现这种情况,如何处理?

最佳答案

UNIQUE 不修改原始系列。函数是否修改通常在它的帮助字符串中提到,例如参见SORT。只需将您的 block 设置为 UNIQUE 的结果,如下所示:

>> a: [1 2 3 4 3 4 4] 
== [1 2 3 4 3 4 4]
>> unique a
== [1 2 3 4]
>> a
== [1 2 3 4 3 4 4]
>> a: unique a
== [1 2 3 4]
>> a
== [1 2 3 4]

关于rebol - block 的唯一性不会删除重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31609202/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com