-
-
Notifications
You must be signed in to change notification settings - Fork 189
Loops
Giorgio Garofalo edited this page Apr 27, 2025
·
6 revisions
The main type of loop is provided by the .foreach
function, which accepts:
- An
Iterable
value; - A 1-parameter lambda block, where the argument is the current item being iterated.
.foreach {2..4}
n:
The number is: **.n**
The number is: 2
The number is: 3
The number is: 4
The function returns an ordered iterable collection of the same size of the input one, containing the evaluation of the lambda for each iterated value.
Thus, the function can be used as an expression:
.row alignment:{spacearound}
.foreach {1..3}
*.1* <!-- .1 is an implicit lambda argument: refers to the first parameter -->
Any iterable value is accepted. Here we use a Markdown list:
.var {letters}
- A
- B
- C
.foreach {.letters}
### .1
The letter is **.1**.
See Iterable for all possible ways of defining an iterable value.
The type of iterated elements is preserved (see Typing for more):
.row alignment:{spacearound}
.foreach {1..5}
n:
.multiply {.n} by:{.n}
The .repeat {times}
function is a shorthand for .foreach {1..times}
.
.repeat {3}
.1
1
2
3
- Figures
- Image size
- TeX formulas
- Table caption
- Decorative headings
- Alerts (quote types)
- Quotation source
- Page breaks
- Text symbols (text replacement)
- Syntax of a function call
- Declaring functions
- Dynamic typing
- Including other Quarkdown files
- Importing external libraries
- Localization
- Document metadata
- Theme
- CSS
- Fonts
- Page format
- Page margin content
- Page counter
- Automatic page break
- Numbering
- Paragraph style
- Caption position
- Table of contents
- Bibliography
- Stacks (row, column, grid)
- Container
- Align
- Float
- Figure
- Clip
- Box
- Collapsible
- Whitespace
- Variables
- Optionality
- Math
- Conditional statements
- Loops
- Let
- Destructuring
- String manipulation
- Table manipulation: sorting, computing, and more
- Generators
- String
- Number
- Markdown content
- Boolean
- None
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic
- Paper: abstract, definitions, theorems, and more