-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFUNCTIONAL_FORMS
39 lines (34 loc) · 1.53 KB
/
FUNCTIONAL_FORMS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
compose:
* Function composition. Feeds its input to the last function in its argument
* list, then feeds that function's output to the second-to-last, and so on,
* eventually returning the output of the last function in the list as the
* combined function's output.
*
* compose{ f, g } : x = f : (g : x)
construct:
* Sequence construction. Feeds its input to each of its argument functions,
* and generate a sequence where each element is the output of one of the
* argument functions.
*
* construct{ f, g } : x = < f : x, g : x >
if:
* Conditional form. Accepts exactly three arguments. First feeds its input
* to the first argument. If the result is boolean True, it feeds the input to
* its second argument, if False then it feeds it to its third argument,
* otherwise it just returns Bottom.
*
* if{ f, g, h } : x = if f : x then g : x else h : x
map:
* Mapping functional form. Accepts a single function argument. Input to the
* form should always be in the form of a list, and the return value will be
* the result of applying the argument function to each element in the list.
*
* map{ f } : < x, y, z > = < f : x, f : y, f : z >
reduce:
* Reducing functional form. Accepts a single function argument. Expects
* input in the form of a list, return value is the result of first applying
* the argument function to a pair formed from the first two elements of the
* input list, then forming a new pair from that result and the next
* right-most element, and so on until the list is exhausted.
*
* reduce{ f } : < x, y, z > = f : < f : < x, y>, z >