// Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; function map(f, a) { let f$1 = x => f(x); let l = a.length; if (l === 0) { return []; } let r = Stdlib_Array.make(l, f$1(a[0])); for (let i = 1; i < l; ++i) { r[i] = f$1(a[i]); } return r; } function init(l, f) { let f$1 = x => f(x); if (l === 0) { return []; } if (l < 0) { throw { RE_EXN_ID: "Invalid_argument", _1: "Array.init", Error: new Error() }; } let res = Stdlib_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { res[i] = f$1(i); } return res; } function fold_left(f, x, a) { let f$1 = (x, y) => f(x, y); let r = x; for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); } return r; } function f2() { let arr = init(30000000, i => i); let b = arr.map(i => i + i - 1); let v = b.reduceRight((prim0, prim1) => prim0 + prim1, 0); console.log(v.toString()); } f2(); let v = { contents: 0 }; let all_v = { contents: /* [] */0 }; function add5(a0, a1, a2, a3, a4) { console.log([ a0, a1, a2, a3, a4 ]); all_v.contents = {hd: v.contents, tl: all_v.contents}; return (((a0 + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0; } function f(x) { v.contents = v.contents + 1 | 0; v.contents = v.contents + 1 | 0; return (extra, extra$1) => add5(x, 1, 2, extra, extra$1); } function g(x) { let u = (a, b) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); all_v.contents = {hd: v.contents, tl: all_v.contents}; return u; } let a = f(0)(3, 4); let b = f(0)(3, 5); let c = g(0)(3, 4); let d = g(0)(3, 5); Mocha.describe("Earger_curry_test", () => { Mocha.test("earger curry a", () => Test_utils.eq("File \"earger_curry_test.res\", line 139, characters 34-41", a, 10)); Mocha.test("earger curry b", () => Test_utils.eq("File \"earger_curry_test.res\", line 140, characters 34-41", b, 11)); Mocha.test("earger curry c", () => Test_utils.eq("File \"earger_curry_test.res\", line 141, characters 34-41", c, 10)); Mocha.test("earger curry d", () => Test_utils.eq("File \"earger_curry_test.res\", line 142, characters 34-41", d, 11)); Mocha.test("earger curry all_v", () => Test_utils.eq("File \"earger_curry_test.res\", line 143, characters 38-45", all_v.contents, {hd: 8, tl: {hd: 6, tl: {hd: 6, tl: {hd: 4, tl: {hd: 4, tl: {hd: 2, tl: /* [] */0}}}}}})); }); export { map, init, fold_left, f2, v, all_v, add5, f, g, a, b, c, d, } /* Not a pure module */