Something went wrong. Try again.
A component based functional template language
Something went wrong. Try again.
1.3 kB · 73 lines
at type-checker
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374component Component { use C = Math.Constants;
let max = fn (a, b) -> { if (a > b) { a } else { b } };
let min = fn (a, b) -> { if (a < b) { a } else { b } };
let until = 5; let map = fn (array, f) -> { for (el in array) { if (min(el, until) == until) continue;
f(el) } };
let add_curry = fn (a) -> { fn (b) -> { a + b } };
let is_even = fn (i) -> { if(i == 0) { true } else { is_odd(i - 1) } };
let is_odd = fn (i) -> { if (i == 0) { false } else { is_even(i - 1) } };
<section> max(1, 5) = {max(1, 5)} min(1, 5) = {min(1, 5)} add_curry(1)(5) = {add_curry(1)(5)} Math.fibonacci(9) = {Math.fibonacci(9)} Math.factorial(5) = {Math.factorial(5)} is_even(10) = {is_even(10)} is_odd(10) = {is_odd(10)}
1 |> max(5) |> Math.factorial = {1 |> max(5) |> Math.factorial} 1 |> add_curry(5)() = {1 |> add_curry(5)()} 5 |> Math.factorial = {5 |> Math.factorial}
Math.Constants.pi = {Math.Constants.pi} C.pi = {C.pi}
Map: {map(1...10, fn (item) -> item ** 2)} Map Pipe: {1...10 |> map(fn (item) -> item ** 2)} </section>}