No matching definitions.

tur/builders

stdlib/seq/builders.tur
defn

seq-call-fn0

(seq-call-fn0 [f :int] :int)

call a zero-arg fat closure stored as int64_t.

defn

seq-call-fn1

(seq-call-fn1 [f :int x :int] :int)
defn

seq-opt-some?

(seq-opt-some? [o :int] :bool)

test whether an option value is non-NULL (some).

defn

seq-opt-unwrap

(seq-opt-unwrap [o :int] :int)
defn

seq-pair-first

(seq-pair-first [p :int] :int)

return the first element of a Tuple2 (legacy name).

defn

seq-pair-second

(seq-pair-second [p :int] :int)
defn

seq/range

(seq/range [start :int end :int] :int)

half-open integer range [start, end).

startinclusive lower bound
endexclusive upper bound

A Seq yielding start, start+1, ..., end-1. Empty if start >= end.

(seq/range 0 5)  ; => 0 1 2 3 4

Since: LZ1

defn

seq/range-step

(seq/range-step [start :int end :int step :int] :int)

integer range with a custom step.

startinclusive start value
endexclusive end value (for positive step) or lower bound (negative)
stepincrement per element (must not be zero)

A Seq yielding start, start+step, start+2*step, ... stopping before end (positive step) or before going below end (negative step).

(seq/range-step 0 10 2)   ; => 0 2 4 6 8
  (seq/range-step 10 0 -3)  ; => 10 7 4 1

Since: LZ1

defn

seq/repeat

(seq/repeat [v :int] :int)

infinite sequence repeating a single value.

vthe value to repeat indefinitely

An infinite Seq always yielding v. Use seq-nth or a bounded iteration to consume.

(seq/repeat 42)  ; => 42 42 42 ...

Since: LZ1

defn

seq/repeatedly

(seq/repeatedly [f :int] :int)

infinite sequence from repeated zero-arg function calls.

fa zero-arg fat closure called to produce each element

An infinite Seq yielding (f), (f), (f), ...

(let [counter (ref 0)]
    (seq/repeatedly (fn [] (let [v @counter] (set-ref! counter (+ v 1)) v))))

Since: LZ1

defn

seq/cycle

(seq/cycle [s :int] :int)

infinite sequence cycling over a finite Seq.

sa finite Seq to cycle

An infinite Seq repeating the elements of s. Returns empty-seq if s is itself empty.

(seq/cycle (seq/range 0 3))  ; => 0 1 2 0 1 2 0 1 2 ...

Since: LZ1

defn

seq/iterate

(seq/iterate [init :int f :int] :int)

infinite sequence x, f(x), f(f(x)), ...

initseed value
fone-arg fat closure applied to produce the next element

A Seq yielding init, f(init), f(f(init)), ...

(seq/iterate 1 (fn [x] (* x 2)))  ; => 1 2 4 8 16 ...

Since: LZ1

defn

seq/unfold

(seq/unfold [seed :int f :int] :int)

build a Seq by unfolding from a seed value.

seedinitial seed value
fone-arg fat closure: seed -> (option (pair value next-seed))
return none to terminate the sequence

A Seq yielding the first element of each pair until f returns none.

(seq/unfold 0 (fn [n]
    (if (< n 5) (some (pair-new n (+ n 1))) (none))))
  ; => 0 1 2 3 4

Since: LZ1