What is the difference between the functions seq?, sequential? and coll?

后端 未结 2 593
时光说笑
时光说笑 2021-01-03 19:49

What is the difference between the functions seq? sequential? and coll?

I found some information scattered throughout the internet, but I think it would be better to

2条回答
  •  星月不相逢
    2021-01-03 20:09

    • seq? is true for any sequence.
    • sequential? is true for any sequential (not associative) collection.
    • coll? is true for any Clojure collection.

    seq? implies sequential? implies coll?

    => ((juxt seq? sequential? coll?) ()) ; [true true true]
    => ((juxt seq? sequential? coll?) []) ; [false true true]
    => ((juxt seq? sequential? coll?) #{}); [false false true]
    

    Inaccurate: sequential? is related to the others purely by convention - see Kevin's answer.

提交回复
热议问题