Skip to content

Iterable

Giorgio Garofalo edited this page May 18, 2025 · 18 revisions

Iterable values are ordered lists or unordered set that can be iterated through a loop.

Iterables can also be destructured: see Destructuring for more.

Collection

An ordered or unordered Markdown list is automatically converted to an ordered collection.

.var {letters}
  - A
  - B
  - C

.foreach {.letters}
  .1::lowercase

a

b

c

Nested collections can be represented by nested Markdown lists as well:

.var {letters}
  - - A
    - B
  - - C
    - D
  - - E
    - F

.foreach {.letters}
  .1::first

A

C

E

Pair

A pair is an iterable of two values.

It may be created via .pair {first} {second} or retrieved as a Dictionary entry.

Dictionary

When used in a function which requires an iterable, a Dictionary value is used as a list of key-value pairs.

Range

An integer Range is a valid ordered iterable value.

Operations

Assuming myiterable to be an iterable, useful operations such as getat, sorted, average and many more can be accessed via function call chaining as .myiterable::operation.

For a complete list of operations, please refer to the stdlib's Collection documentation.

Clone this wiki locally