1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/*
You can do anything with map + reduce!
*/
import { createFn } from "../src";
const concatNumbers = createFn<[number[]]>()(
`fn(a, reduce(map(a, fn(n, tostring(n))), fn(acc, cur, add(acc,cur)), ""))`
);
// const result: "1235"
const concatted = concatNumbers([1, 2, 35]);
console.log(concatted);
const arrayLength = createFn<[any[]]>()(
`fn(a, reduce(a, fn(acc, add(acc, 1)), 0))`
);
// const length: 2
const length = arrayLength(["hello", "world"]);
console.log(length);
|