来自 Slack: https://clojurians.slack.com/archives/C03S1KBA2/p1662437976861689
(range 0 5 1.0) ;=> (0 1.0 2.0 3.0 4.0)
(with-meta (range 0 5 1.0) {}) ;=> (5)
user=> (def x (range 0 5 1.0))
#'user/x
user=> x
(0 1.0 2.0 3.0 4.0)
user=> (with-meta x {})
(5 1.0 2.0 3.0 4.0)
我发现看起来可能存在一些出序参数,称为
Range.java 中的 with-meta 调用
public Obj withMeta(IPersistentMap meta){
if(meta == _meta)
return this;
return new Range(meta, end, start, step, boundsCheck, _chunk, _chunkNext);
}
该构造器中 end 和 start 顺序颠倒
private Range(IPersistentMap meta, Object start, Object end, Object step, BoundsCheck boundsCheck, IChunk chunk, ISeq chunkNext){