programdemos/apply.xtl
Calling a function of several arguments, three ways
(docs/several-arguments.md). Every X_eTaL function takes one
argument: x f y is (f x) y, so a third argument goes to the
function that call gives, as an applied group (...) z.
Run it with ./demos/apply.xtl or "xetal run demos/apply.xtl"; each way prints 4321. "xetal expand demos/apply.xtl" shows what the macro of the second way wrote.
ᵘf̲ : Num a => a -> a -> a -> a -> a
a b c d u:f_: the digits a, b, c and d as one number, a the ones.
ᵘf̲ ← { a b c d → a + (10 × b) + (100 × c) + 1000 × d }
ᵘg̲ : Num a => (a, a, a, a) -> a
u:g_ (a, b, c, d): the same number, its four digits as one tuple.
ᵘg̲ ← { (a, b, c, d) → a + (10 × b) + (100 × c) + 1000 × d }
Used in: demos/apply.xtl:27
ᵘf̲irstThree : Int -> Int
u:f_irstThree d: 321 plus 1000 d.
ᵘf̲irstThree ← (1 ᵘf̲ 2) 3
Used in: demos/apply.xtl:33