Lists, functions and control flow
Documentation status: guide — see Maturity and evidence.
functionalP includes list-oriented expressions, ranges, conditions, loops, named functions, and advanced functional forms.
Lists and ranges
(1, 2, 3);
();
(1, 2, (5, 4, 6));
1 .. 5;
Useful list operators include head, tail, last, length, reverse, drop, and take.
tail (1, 2, 3);
length (1, 2, 3, 4);
reverse (1, 2, 3);
Conditional execution
status := 0;
if (status = 0) then
begin
Result := 'ready';
end
else
begin
Result := 'blocked';
end;
Loops
sum := 0;
for value in (1, 2, 3, 4) do
begin
sum := sum + value;
end;
Result := sum;
Loops should remain small. Cross-object or long-running coordination belongs in a process model.
Named functions
function double(value)
begin
value * 2;
end;
Result := double(4);
A function can be used with functional operators:
Result := map double (1 .. 5);
Lambdas and case expressions
These are advanced features. Use them for local transformations, not to hide durable business rules.
Result := (lambda(x) x * x) 4;
function normalize(value)
begin
case value of
() :- ()
| _ :- value
end;
end;