No matching definitions.

tur/range

stdlib/range.tur

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

Since: Phase LZ4

defgadt

Bound

(defgadt Bound :copy [A] (Inclusive) (Bound) (Exclusive) (Bound) (Unbounded) (Bound))

a range endpoint: inclusive, exclusive, or unbounded.

Since: LZ4 (GADT form: range-gadt-typeclass-migration-plan B1)

defn

range-bound-new

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

build a Bound with given inclusivity and value.

inclusive1 for inclusive, 0 for exclusive
valuethe endpoint value

A (Bound int): Inclusive when inclusive=1, else Exclusive.

Since: LZ4

defn

bound-unbounded?

(bound-unbounded? [b : Bound] :)

true if the endpoint is the Unbounded constructor.

ba (Bound int)

Since: range-gadt-typeclass-migration-plan B1

defn

range-bound-inclusive?

(range-bound-inclusive? [b : Bound] :)

true if the bound is inclusive.

ba (Bound int) (must not be Unbounded)

Since: LZ4

defn

range-bound-value

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

return the endpoint value of a bound.

ba (Bound int) (Unbounded yields 0)

Since: LZ4

defn

range-bound-flip

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

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

ba (Bound int) (must not be Unbounded)

Since: LZ4

definstance

Eq[Bound]

(definstance Eq [Bound])

structural equality on range endpoints.

(.eq? (Inclusive 3) (Inclusive 3))  ; => true
  (.eq? (Inclusive 3) (Exclusive 3))  ; => false

Since: range-gadt-typeclass-migration-plan B2

defn

bound-show-fmt

(bound-show-fmt [kind : int v : int] :)
definstance

Show[Bound]

(definstance Show [Bound])

render a lone endpoint: "[v" (Inclusive), "(v" (Exclusive),

(show (Inclusive 3))  ; => "[3"
  (show (Unbounded))    ; => "unbounded"

Since: range-gadt-typeclass-migration-plan B2

defn

bound-lt?

(bound-lt? [x : Bound y : Bound] :)

strict total order on Bound endpoints, backing Ord [Bound].

xthe left (Bound int)
ythe right (Bound int)

true when x sorts strictly before y.

(bound-lt? (Unbounded) (Inclusive 0))    ; => true
  (bound-lt? (Inclusive 5) (Exclusive 5))  ; => true

Since: range-gadt-typeclass-migration-plan B2

definstance

Ord[Bound]

(definstance Ord [Bound])

total ordering on endpoints (see bound-lt? for semantics).

defn

range-new

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

allocate a Range from lower and upper Bound endpoints.

lowerthe lower (Bound int) (Unbounded for unbounded below)
upperthe upper (Bound int) (Unbounded for unbounded above)

int64_t pointer to a heap Range.

Since: LZ4

defn

range-lower

(range-lower [r : int] :)

return the lower Bound endpoint.

rint64_t pointer to a Range

Since: LZ4

defn

range-upper

(range-upper [r : int] :)

return the upper Bound endpoint.

rint64_t pointer to a Range

Since: LZ4

defn

range-abort-not-connected

(range-abort-not-connected :)
defn

range-abort-connected

(range-abort-connected :)
defn

range-abort-unbounded-lower

(range-abort-unbounded-lower :)
defn

closed-range

(closed-range [lo : int hi : 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] :)

(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] :)

[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] :)

(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] :)

[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] :)

(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] :)

(-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] :)

(-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] :)

[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 :)

(-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 : Bound v : int] :)
defn

range-val-in-upper?

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

range-bound-strictly-before?

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

range-bound-has-gap?

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

range-contains?

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

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] :)

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] :)

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] :)

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] :)

true if both endpoints are present.

rint64_t pointer to a Range

Since: LZ4

defn

bounded-above?

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

true if r has an upper bound.

rint64_t pointer to a Range

Since: LZ4

defn

bounded-below?

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

true if r has a lower bound.

rint64_t pointer to a Range

Since: LZ4

defn

unbounded-above?

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

true if r has no upper bound.

rint64_t pointer to a Range

Since: LZ4

defn

unbounded-below?

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

true if r has no lower bound.

rint64_t pointer to a Range

Since: LZ4

defn

singleton-range?

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

true if r contains exactly one value.

rint64_t pointer to a Range

Since: LZ4

defn

empty-range?

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

true if r contains no values.

rint64_t pointer to a Range

Since: LZ4

defn

nonempty-range?

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

true if r contains at least one value.

rint64_t pointer to a Range

Since: LZ4

defn

range-lower-min

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

range-upper-max

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

range-lower-max

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

range-upper-min

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

range-span

(range-span [r1 : int r2 : 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] :)

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] :)

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] :)

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] :)

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