/* https://bucklescript.github.io/bucklescript/api/Belt.html */
module A = Belt.Array;
module L = Belt.List;
let myArray = A.rangeBy(1, 10, ~step=1);
Js.log(myArray);
let myList = L.fromArray(myArray);
Js.log(myList);
let isEven = i => i mod 2 == 0;
A.keep(myArray, isEven)->Js.log;
L.keep(myList, j => j mod 2 == 0)->Js.log;
let double = i => i * 2;
A.map(myArray, double)->Js.log;
L.map(myList, ( * )(2))->Js.log;
let add = (i, j) => i + j;
A.reduce(myArray, 0, add)->Js.log;
L.reduce(myList, 0, (+))->Js.log;
$ node src/Demo.bs.js
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
[ 1,
[ 2,
[ 3, [ 4, [ 5, [ 6, [ 7, [ 8, [ 9, [ 10, 0 ] ] ] ] ] ] ] ] ] ]
[ 2, 4, 6, 8, 10 ]
[ 2, [ 4, [ 6, [ 8, [ 10, 0 ] ] ] ] ]
[ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 ]
[ 2,
[ 4,
[ 6, [ 8, [ 10, [ 12, [ 14, [ 16, [ 18, [ 20, 0 ] ] ] ] ] ] ] ] ] ]
55
55