A sequence expression lets you do a few local steps and still give back one value.
It uses parentheses. Do not use braces for this. Braces belong to records and named forms such as data, effect, shape, given, answer, quote, and unsafe.
(
let base := 8000;
let offset := 80;
base + offset
);The names inside the sequence are local. They are like notes on a small notepad. They help with one task, then they go away.
The final expression is the value of the sequence. This makes a sequence useful inside a larger expression.
Use a sequence when one line becomes crowded. Give the small steps names, then return the value you wanted.
Sequence value
The final expression in a sequence becomes the sequence value.
let doubled := (
let input := 21;
input * 2 -- 42
);doubled receives 42. The helper name input stays inside the sequence.
Semicolons
Use semicolons between statements in a sequence expression.
let value := (
let base := 40;
base + 2 -- 42
);The final expression may be the returned value of the sequence.