Elements of FL syntax

FL is a pure functional language based on combinatorial logic.
The language introduces an algebra over programs (a set of algebraic identities between functional expressions) for reasoning formally about programs, so that one may find simpler equivalent programs (both at design and at compile times); programs are easily combined, so that new programs are obtained in a simple and elegant way; great advantages in style and efficiency of program development are achieved.

Primitive objects
characters, numbers and truth values

Expressions
primitive objects, functions, applications and sequences

Sequences
expressions separated by commas and contained within a pair of angle brackets: <5, fun>

The application expression
exp1:exp2 applies the function resulting from the evaluation of exp1 on the argument resulting from the evaluation of exp2.

Binary functions
can also be used in infix form: +:<1,3> = 1 + 3 = 4

Application associates to left:
f:g:h = (f:g):h

Application binds stronger than composition:
f:g ~ h = (f:g) ~ h

FL combining forms and functions:
The construction combining form CONS
allows to apply a sequence of functions to an argument producing the sequence of applications:
CONS:< f1,...,fn >:x = [f1,...,fn]:x = < f1:x,...,fn:x >

E.g. CONS:<+,->, written also [+,-], when applied to the argument <3,2> gives the sequence of applications:
[+,-]:<3,2> = <+:<3,2>,-:<3,2>> = <5,1>;

The apply-to-all combining form AA
applies a function to a sequence of arguments giving a sequence of applications: AA:f:< x1,...,xn > = < f:x1,...,f:xn >;

The identity function ID
returns its argument unchanged: ID:x = x;

The constant function K
is evaluated, for whatever x2, as: K:x1:x2 = x1;

Binary composition ~ of functions
is defined as (f ~ g):x = f:(g:x);

N-ary composition COMP of functions
is also allowed: COMP:< f,h,g >:x = (f ~ h ~ g):x = f:(h:(g:x));

The conditional form
IF:< p,f,g >:x is evaluated as follows:
IF:< p,f,g >:x = f:x if p:x = TRUE g:x if p:x = FALSE

The insert right and insert left combining forms (INSR and INSL)
allow to apply a binary function on a sequence of arguments of any length: INSR:f:< x1,x2,...,xn > = f:< x1, INSR:f:< x2,...,xn > >
INSL:f:< x1,...,xn-1,xn > = f:< INSL:f:< x1,...,xn-1 >, xn >,
where INSR:f:< x > = INSL:f:< x > = x

The catenate function CAT
appends any number of input sequences creating a single output sequence: CAT:<< a,b,c >,< d,e >,...,< x,y,z >> = < a,b,c,d,e,...,x,y,z >

The distribute right and distribute left functions (DISTR, DISTL)
generate a sequence of pairs:
DISTR:<< a,b,c >, x> = << a,x >, < b,x >, < c,x >>
DISTL:< x,< a,b,c >> = << x,a >, < x,b >, < x,c >>

PLaSM is Free Software and may be distributed under GNU LGPL