tur/combine
seq-make-pair
(seq-make-pair [a :int b :int] :int)
allocate a heap Tuple2 { e1, e2 } (legacy name kept
| a | first element (int64_t) | |
| b | second element (int64_t) |
int64_t pointer to a heap Tuple2 { int64_t e1; int64_t e2; } struct.
Since: LZ3
seq/concat
(seq/concat [s1 :int s2 :int] :int)
yield all elements of s1 followed by all elements of s2.
| s1 | first source Seq | |
| s2 | second source Seq |
A Seq yielding every element of s1 then every element of s2.
(seq-for-each println (seq/concat (seq/range 0 3) (seq/range 10 12))) ; => 0 1 2 10 11
Since: LZ3
seq/chain
(seq/chain [s :int] :int)
yield all elements of each inner Seq in a Seq of Seqs.
| s | a Seq whose elements are themselves Seqs (int64_t pointers) |
A Seq yielding all elements of every inner Seq, in order. Equivalent to seq/flatten from transform.tur.
(seq-for-each println (seq/chain (seq-of (seq/range 1 3)))) ; => 1 2
Since: LZ3
seq/zip
(seq/zip [s1 :int s2 :int] :int)
pair corresponding elements from two Seqs; stops at the shorter.
| s1 | first source Seq | |
| s2 | second source Seq |
A Seq of pairs (int64_t pointers to { first, second }) where each pair contains one element from s1 and the corresponding element from s2. Terminates when either source is exhausted.
(seq-for-each (fn [p] (let [_d p] (println (seq-pair-first p)))) (seq/zip s1 s2))
Since: LZ3
seq/zip-with
(seq/zip-with [f :int s1 :int s2 :int] :int)
combine corresponding elements from two Seqs using f.
| f | fat closure (a b -> c) applied to each element pair | |
| s1 | first source Seq | |
| s2 | second source Seq |
A Seq yielding f(a, b) for each corresponding pair; stops at the shorter.
(let [add (fn [a b] (let [_ a] (+ a b)))]
(seq-for-each println (seq/zip-with add (seq/range 0 3) (seq/range 10 13))))
; => 10 12 14
Since: LZ3
seq/interleave
(seq/interleave [s1 :int s2 :int] :int)
alternate elements from s1 and s2; stops when either ends.
| s1 | first source Seq (yields a0, a1, a2, ...) | |
| s2 | second source Seq (yields b0, b1, b2, ...) |
A Seq yielding a0, b0, a1, b1, ... stopping when either source is exhausted after a pair is consumed.
(seq-for-each println (seq/interleave (seq/range 0 3) (seq/range 10 13))) ; => 0 10 1 11 2 12
Since: LZ3