Scripting reference · Nerdamer Language
for
Repeats an expression with a start, a condition and a step.
start runs once. Then, while condition is true, body runs, followed by step.
Scripting
for(start, condition, step, body)
Write it in a script: nerdamer('block(k:0,total:0,for(k:0,4-k,k:k+1,total:total+k),total)'), or in the Playground.
Parameters
start- Runs once before the loop, usually an assignment such as
k:0. condition- Checked before each pass; the loop stops when it is false.
step- Runs after each pass, such as
k:k+1. body- The expression to repeat.
Examples
Add 0, 1, 2 and 3.
block(k:0,total:0,for(k:0,4-k,k:k+1,total:total+k),total)
// → 6Open in PlaygroundThe loop variable is still set afterwards.
block(k:0, for(k:0, k<3, k:k+1, 0), k)
// → 3Open in PlaygroundGood to know
continue()still runsstep;break()andreturnskip it.- The same
MAX_LOOP_ITERATIONSlimit aswhileapplies.
