Replies: 2 comments 7 replies
-
Perhaps we should have a separate (ns foo (:require [clava.generators :as gen]))
(take 10 (gen/range)) |
Beta Was this translation helpful? Give feedback.
-
I think a way we can do this is create a custom type that is iterable. So something like class Range {
constructor(begin, end) {
this.begin = begin || 0;
this.end = end;
}
*[Symbol.iterator]() {
let i = this.begin;
while (i !== this.end) {
yield i++;
}
}
}
function range(begin, end) {
return new Range(begin, end);
} The (take 10 (range))
(into [] (comp (filter even?) (map inc) (take 10)) (range)) We can also have |
Beta Was this translation helpful? Give feedback.
-
E.g.
(range)
,(repeat :foo)
,(cycle [1 2 3])
etc. They could be built on iterators, but the surprise lies in the fact that they can be only iterated once. Can and should we do something about that?/cc @lilactown
Beta Was this translation helpful? Give feedback.
All reactions