Fix bug in apply checking
[minfp.git] / tests / preamble.mfp
1 //Function application
2 $ ifxr 0 x y = x y;
3 //Reverse function application
4 & ifxr 0 x y = y x;
5
6 //Arithmetic operators
7 == ifxl 7 = code eq;
8 * ifxl 7 = code mul;
9 - ifxl 6 = code sub;
10 + ifxl 6 = code add;
11
12 on f g a b = f (g a) (g b);
13 onn = \f. \g. \a. \b. f (g a) (g b);
14
15 //Conditional operators
16 if = code if;
17
18 //fac i = if (i == 0) 1 $ i * fac (i - 1);
19 id x = x;
20
21 even i = if (i == 0) True (odd (i - 1));
22 odd i = if (i == 0) False (even (i - 1));
23
24 //start = on;
25 start = \f. \g. \a. \b. f (g a) (g b);