No matching definitions.

tur/range

stdlib/range.tur

Range: continuous interval with inclusive, exclusive, or unbounded ends.

Since: Phase LZ4

defn

range-bound-new

(range-bound-new [inclusive :int value :int] :int)

allocate a RangeBound with given inclusivity and value.

inclusive1 for inclusive, 0 for exclusive
valuethe endpoint value

int64_t pointer to a heap RangeBound.

Since: LZ4

defn

range-bound-inclusive?

(range-bound-inclusive? [b :int] :bool)

true if the bound is inclusive.

bint64_t pointer to a RangeBound (must not be 0)

Since: LZ4

defn

range-bound-value

(range-bound-value [b :int] :int)

return the endpoint value of a bound.

bint64_t pointer to a RangeBound (must not be 0)

Since: LZ4

defn

range-bound-flip

(range-bound-flip [b :int] :int)

return a new bound with the same value but flipped inclusivity.

bint64_t pointer to a RangeBound (must not be 0)

Since: LZ4

defn

range-new

(range-new [lower :int upper :int] :int)

allocate a Range from lower and upper bound pointers.

lower0 for unbounded below, else RangeBound pointer
upper0 for unbounded above, else RangeBound pointer

int64_t pointer to a heap Range.

Since: LZ4

defn

range-lower

(range-lower [r :int] :int)

return the lower bound pointer (0 = unbounded).

rint64_t pointer to a Range

Since: LZ4

defn

range-upper

(range-upper [r :int] :int)

return the upper bound pointer (0 = unbounded).

rint64_t pointer to a Range

Since: LZ4

defn

range-abort-not-connected

(range-abort-not-connected :int)
defn

range-abort-connected

(range-abort-connected :int)
defn

range-abort-unbounded-lower

(range-abort-unbounded-lower :int)
defn

closed-range

(closed-range [lo :int hi :int] :int)

[lo, hi] both endpoints inclusive.

lolower bound value
hiupper bound value

A Range representing [lo, hi].

(closed-range 1 5)  ; => [1, 5]

Since: LZ4

defn

open-range

(open-range [lo :int hi :int] :int)

(lo, hi) both endpoints exclusive.

lolower bound value (excluded)
hiupper bound value (excluded)

A Range representing (lo, hi).

(open-range 1 5)  ; => (1, 5)

Since: LZ4

defn

closed-open-range

(closed-open-range [lo :int hi :int] :int)

[lo, hi) inclusive lower, exclusive upper.

lolower bound value (included)
hiupper bound value (excluded)

A Range representing [lo, hi).

(closed-open-range 1 5)  ; => [1, 5)

Since: LZ4

defn

open-closed-range

(open-closed-range [lo :int hi :int] :int)

(lo, hi] exclusive lower, inclusive upper.

lolower bound value (excluded)
hiupper bound value (included)

A Range representing (lo, hi].

(open-closed-range 1 5)  ; => (1, 5]

Since: LZ4

defn

at-least-range

(at-least-range [lo :int] :int)

[lo, +inf) inclusive lower, unbounded above.

lolower bound value (included)

A Range representing [lo, +inf).

(at-least-range 5)  ; => [5, +inf)

Since: LZ4

defn

greater-than-range

(greater-than-range [lo :int] :int)

(lo, +inf) exclusive lower, unbounded above.

lolower bound value (excluded)

A Range representing (lo, +inf).

(greater-than-range 5)  ; => (5, +inf)

Since: LZ4

defn

at-most-range

(at-most-range [hi :int] :int)

(-inf, hi] unbounded below, inclusive upper.

hiupper bound value (included)

A Range representing (-inf, hi].

(at-most-range 5)  ; => (-inf, 5]

Since: LZ4

defn

less-than-range

(less-than-range [hi :int] :int)

(-inf, hi) unbounded below, exclusive upper.

hiupper bound value (excluded)

A Range representing (-inf, hi).

(less-than-range 5)  ; => (-inf, 5)

Since: LZ4

defn

singleton-range

(singleton-range [v :int] :int)

[v, v] a range containing exactly one value.

vthe single value

A Range representing [v, v].

(singleton-range 3)  ; => [3, 3]

Since: LZ4

defn

unbounded-range

(unbounded-range :int)

(-inf, +inf) no bounds at all.

A Range representing all values.

(unbounded-range)  ; => (-inf, +inf)

Since: LZ4

defn

range-val-in-lower?

(range-val-in-lower? [b :int v :int] :bool)
defn

range-val-in-upper?

(range-val-in-upper? [b :int v :int] :bool)
defn

range-bound-strictly-before?

(range-bound-strictly-before? [u :int l :int] :bool)
defn

range-bound-has-gap?

(range-bound-has-gap? [u :int l :int] :bool)
defn

range-contains?

(range-contains? [r :int v :int] :bool)

true if value v falls within range r.

rint64_t pointer to a Range
vvalue to test

true if v satisfies both the lower and upper bounds of r.

(range-contains? (closed-range 1 5) 3)  ; => true
  (range-contains? (open-range 1 5) 1)    ; => false

Since: LZ4

defn

range-encloses?

(range-encloses? [r :int other :int] :bool)

true if every value in other is also in r.

rthe outer Range
otherthe inner Range

true if r's lower <= other's lower and r's upper >= other's upper (accounting for inclusive/exclusive endpoints).

(range-encloses? (closed-range 0 10) (closed-range 2 8))  ; => true

Since: LZ4

defn

range-connected?

(range-connected? [r1 :int r2 :int] :bool)

true if no gap exists between r1 and r2.

r1first Range
r2second Range

true if r1 and r2 are connected.

(range-connected? (closed-open-range 1 3) (closed-range 3 5))  ; => true
  (range-connected? (less-than-range 3) (greater-than-range 3))  ; => false

Since: LZ4

defn

range-overlaps?

(range-overlaps? [r1 :int r2 :int] :bool)

true if r1 and r2 share at least one common value.

r1first Range
r2second Range

true if there exists a value contained in both r1 and r2.

(range-overlaps? (closed-range 1 3) (closed-range 3 5))  ; => true
  (range-overlaps? (closed-open-range 1 3) (closed-range 3 5))  ; => false

Since: LZ4

defn

bounded-range?

(bounded-range? [r :int] :bool)

true if both endpoints are present.

rint64_t pointer to a Range

Since: LZ4

defn

bounded-above?

(bounded-above? [r :int] :bool)

true if r has an upper bound.

rint64_t pointer to a Range

Since: LZ4

defn

bounded-below?

(bounded-below? [r :int] :bool)

true if r has a lower bound.

rint64_t pointer to a Range

Since: LZ4

defn

unbounded-above?

(unbounded-above? [r :int] :bool)

true if r has no upper bound.

rint64_t pointer to a Range

Since: LZ4

defn

unbounded-below?

(unbounded-below? [r :int] :bool)

true if r has no lower bound.

rint64_t pointer to a Range

Since: LZ4

defn

singleton-range?

(singleton-range? [r :int] :bool)

true if r contains exactly one value.

rint64_t pointer to a Range

Since: LZ4

defn

empty-range?

(empty-range? [r :int] :bool)

true if r contains no values.

rint64_t pointer to a Range

Since: LZ4

defn

nonempty-range?

(nonempty-range? [r :int] :bool)

true if r contains at least one value.

rint64_t pointer to a Range

Since: LZ4

defn

range-lower-min

(range-lower-min [b1 :int b2 :int] :int)
defn

range-upper-max

(range-upper-max [b1 :int b2 :int] :int)
defn

range-lower-max

(range-lower-max [b1 :int b2 :int] :int)
defn

range-upper-min

(range-upper-min [b1 :int b2 :int] :int)
defn

range-span

(range-span [r1 :int r2 :int] :int)

smallest range enclosing both r1 and r2 (convex hull).

r1first Range
r2second Range

A Range whose lower bound is the min of both lowers and whose upper bound is the max of both uppers.

(range-span (closed-range 1 3) (closed-range 5 8))  ; => [1, 8]

Since: LZ4

defn

range-intersection

(range-intersection [r1 :int r2 :int] :int)

largest range enclosed by both r1 and r2.

r1first Range
r2second Range

A Range representing the intersection of r1 and r2.

(range-intersection (closed-range 1 5) (closed-range 3 8))  ; => [3, 5]

Since: LZ4

defn

range-gap

(range-gap [r1 :int r2 :int] :int)

largest range lying strictly between r1 and r2.

r1first Range
r2second Range

A Range representing the gap between r1 and r2. The gap's bounds are the flipped endpoints of whichever range ends first and whichever starts second.

(range-gap (closed-range 1 3) (closed-range 5 8))    ; => (3, 5)
  (range-gap (closed-open-range 1 3) (open-range 3 8)) ; => [3, 3]

Since: LZ4

defn

seq/from-range

(seq/from-range [r :int] :int)

convert a bounded integer Range to a lazy Seq.

rint64_t pointer to a Range (integer endpoints)

A Seq yielding each integer in r in ascending order.

(seq-for-each println (seq/from-range (closed-range 1 4)))  ; => 1 2 3 4
  (seq-for-each println (seq/from-range (open-range 1 5)))    ; => 2 3 4

Since: LZ4

defn

seq/from-range-step

(seq/from-range-step [step :int r :int] :int)

convert a bounded integer Range to a Seq with a custom step.

stepincrement per element (nonzero)
rint64_t pointer to a Range (integer endpoints)

A Seq yielding each integer in r at the given step.

(seq-for-each println (seq/from-range-step 2 (closed-range 0 8)))
  ; => 0 2 4 6 8

Since: LZ4