This module implements a bunch of higher-order functions on the functional lists, typically the ones from the so-called Map-Reduce framework : listMap, listReduce and listFilter.
Here are some ways to use these functions :
import { anyToString } from "#src/utils/printers.js";import { listIota } from "#src/utils/list.functional.api.js";import { listFilter, listReduce } from "#src/utils/list.functional.higher.js";const aList1 = listIota(0, 10);anyToString(aList1); // -> (| 0, ... 9 |)const aList2 = listFilter(aList1, (el) => el % 2 === 0);anyToString(aList2); // -> (| 0, 2, 4, 6, 8 |)const aString = listReduce(aList2, (acc, el) => acc + el, "");anyToString(aString); // -> "02468" Copy
import { anyToString } from "#src/utils/printers.js";import { listIota } from "#src/utils/list.functional.api.js";import { listFilter, listReduce } from "#src/utils/list.functional.higher.js";const aList1 = listIota(0, 10);anyToString(aList1); // -> (| 0, ... 9 |)const aList2 = listFilter(aList1, (el) => el % 2 === 0);anyToString(aList2); // -> (| 0, 2, 4, 6, 8 |)const aString = listReduce(aList2, (acc, el) => acc + el, "");anyToString(aString); // -> "02468"
This module implements a bunch of higher-order functions on the functional lists, typically the ones from the so-called Map-Reduce framework : listMap, listReduce and listFilter.
Example
Here are some ways to use these functions :