kex docs Standard Library

Range

type Range

Range — a range computes everything from its two bounds; items materializes the elements into a real list when one is needed.

Implements Enumerable, Foldable.

Methods

reduce Enumerable Foldable

reduce(acc, f)

Shared primitive for Enumerable and Foldable. Range stays structurally minimal; inherited operations reduce over its materialized items in ascending range order.

sum

Numeric range aggregates are expressed in terms of the Enumerable primitive rather than relying on the walker's historical List fallback.

contains?

contains?(value)

Membership is a Range method, not a fallback into the bare String/List native dispatcher.

items

The range's elements as a list.

Examples
(1..3).items      # => [1, 2, 3]
('a'..'c').items  # => ['a', 'b', 'c']

first

The list operations, over the materialized items. A range is an ordered collection, so (1..5).first and (1..5).length are questions it can answer — and on the BEAM backend, where a range IS its item list, they already worked. Only the walker rejected them ("Undefined method: first for Range"), so every one of these was a backend divergence rather than a deliberate restriction.

max

min

sort

sort(comparator)

join

join(separator)

at

at(index, fallback)

take

take(n)

drop

drop(n)

indexOf

indexOf(value)

zip

zip(other)

partition

partition(pred)

push

push(value)

reject

reject(pred)

From Enumerable

map
Transforms each item by applying f, collecting the results into a list.
mapIndexed
Transforms each item together with its 0-based position, collecting the results into a list.
filter
Keeps the items for which pred holds.
flatMap
Maps each item to a list and concatenates the results.
collect
Maps each item through f (returning an Optional), keeping and unwrapping the Just(y) results and dropping None.

From Foldable

each
Applies f to each item for its side effects.
eachIndexed
Applies f to each item together with its 0-based position, for side effects.
all?
True if every item satisfies pred.
any?
True if at least one item satisfies pred.
find
The first item satisfying pred wrapped in Just, or None.