Guides
Control Flow
This page documents control flow. Squiggle has if/else statements, but not for loops. Instead of for loops, you can use reduce/map constructs, which are also documented here.
Conditionals
If-else
If-else as a ternary operator
Tips and tricks
Use brackets and parenthesis to organize control flow
or
This is overkill for simple examples becomes useful when the control conditions are more complex.
Save the result to a variable
Assigning a value inside an if/else flow isn't possible:
Instead, you can do this:
Likewise, for assigning more than one value, you can't do this:
Instead, do:
For loops
For loops aren't supported in Squiggle. Instead, use a map or a reduce function.
Instead of:
do:
Edit on GitHub
Last updated on