Up: Index. Previous: Introduction. Next: Menus.
Lambda expressions are built based on four simple rules.
x.x" represents the identity function.
Without parentheses, a function application has a higher order of
precedence than function abstraction, and function applications are
left-associative. For example, the expression
"
x.f g x"
would represent a function that takes in an argument x and
returns the
result of applying g to f, then x to the
function that this returns.
If you want instead to pass x to g and the result to
f, you would need parentheses:
"
x.f (g x)". This latter expression would represent a
function the functional composition of f and g.
Thus, when we consider the lambda expression
x.* x x) (- 3 1)
The following lambda expression is a more difficult one.
f.
z.f (f z)) (
x.* x x) (- 3 1)
x.* x x" into this
function as f, and so we get the function taking z as
a parameter and returning the value of
x.* x x) ((
x.* x x) z)
x.* x x) (* 2 2)
x.* x x) 4When the "Use Applied Calculus" option is selected (as it is by default), the engine includes a variety of computational functions already.
| +, -, *, / | take two numerical identifiers and return an identifier representing the binary operation applied to them. |
|---|---|
| <, >, <=, >=, =, /= | take two numerical identifiers and return the identifier true or false representing how they compare. (The /= function represents inequality.) |
| if | take three values, the first being the identifier true or false, returning the second value if the identifier is true and the third if it is false. |
Note: If you have selected the applicative evaluation, the built-in if function will not necessarily compute as you might expect. The engine will attempt to evaluate all three arguments first before applying the if function, which could lead to unnecessary infinite computation.
Up: Index. Previous: Introduction. Next: Menus.