iterable - iamgio/quarkdown GitHub Wiki

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

Iterables can be destructured: see Destructuring for more.

Types

Markdown list

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

Note

This feature is currently limited:

  • The text content of each item is used as a dynamic value, allowing it to be adapted to any other type as invocation time;
  • Nested lists are not supported.
.var {letters}
  - A
  - B
  - C

.foreach {.letters}
  .lowercase {.1}

a

b

c

Pair

A pair is an iterable of two values.

It may be created via .pair {first} {second} or retrieved from a Dictionary's 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

The following operations on iterables are valid (note that indexes start at 1):

  • .getat {index} {iterable}
  • .getat {index} {iterable} {orelse} (fallback value if the index is out of bounds)
  • .first {iterable}
  • .second {iterable}
  • .third {iterable}
  • .last {iterable}
⚠️ **GitHub.com Fallback** ⚠️