我正试图解决这个问题
我意识到这句话的输出是假的。
(= (#(into [] (distinct %)) [1 2 3])
'(1 1 2 2 3 3))
它应该是真的,因为函数也返回相同的向量。
有人能给我解释一下为什么这是假的吗?
发布于 2020-12-19 23:50:26
从评论中,我发现我不正确地使用了不同的方法,因此决定使用重复方法来得到答案,即:
mapcat #(repeat 2 %)
发布于 2021-01-21 03:58:37
您问的问题与您提到的问题无关,your own answer解决了这个问题。只看问题..。
distinct
应用于错误的distinct
,您可以将=
应用于任意两个序列。您不必将distinct
生成的惰性序列转换为向量.因此以下几点就足够了..。
(= [1 2 3] (distinct '(1 1 2 2 3 3)))
=> true
https://stackoverflow.com/questions/65374557
复制