Examples
Two programs that do real work. Both are live: change the inputs, edit the code, break it on purpose. Nothing here is a screenshot.
A grade from a score
Section titled “A grade from a score”Symbols, a condition, and two outputs that share their working.
Things worth noticing:
>=in$score >= 60is a symbol, and symbols are sugar. This one becomesNot(LessThan($score, 60)), which is why there is noGreaterThanOrEqualop to look up. See Operators and symbols.adjustedis read twice, bytopMarkand by thefinalScoreoutput, and computed once. A binding is a name for a value, not a macro.- The diagnostics line stays quiet until you break something. Delete the
60and it tells you where, before anything runs.
A roll-up over three lists
Section titled “A roll-up over three lists”Lists, a lambda, and an input the lambda closes over.
Concat,Filter,LengthandAverageare ordinary ops. There is no list syntax and no loop; iteration is what these are for.height => height >= $thresholdis a lambda and a real closure: it captures$thresholdfrom around it. Change the threshold andhowManyTallmoves whileaveragedoes not, becauseaveragenever reads it.- The three lists are separate inputs. One input holding a record with three fields would say the same thing, and will once a layer can declare its own struct types.
Take one apart
Section titled “Take one apart”Both programs are in the repository, and both are checked by a test on every build, so they cannot drift from the language. Open either in the playground with the corner button, change whatever you like, and the URL becomes a link to exactly what you made. piece at a time.