-
-
Notifications
You must be signed in to change notification settings - Fork 3
Control Flow
LSTS offers a standard assortment of control flow operators.
Ternary if
can be used in expression position.
print(if condition then "true" else "false")
Match expressions permit destructuring of data in a controlled intentional manner.
match xyz {
XY { x-field: X { i } } => print(i);
XYZ { z-field: Z { i } } => print(i);
}
match
can destructure lots of things, such as strings or lists.
match "abc" {
"a".. _ => print("starts with A");
r/^a+/.. _ => print("starts with at least one A")
};
match [1,2,3] {
[1.. 2.. _] => print("starts with 1, 2, ...");
};
While loops are a common feature available in most languages.
while x < 2 { x += 1; }
For loops allow the programmer to traverse through iterable data.
for x in [1,2,3] { print(x); }
Expressions and statements can be evaluated sequentially with the semicolon syntax.
print("hello"); 5
//prints hello, then evaluates to 5
Manually adding types is not strictly necessary, but can be useful for debugging.
t : T
The LSTS source code and documentation are released under the terms of the attached permissive MIT license. This license is intended only to protect the future development of the project while otherwise allowing people to use the code and IP as they would like. Please, just be nice.