From ef7f6fb0e1eb6b263d5e58c45f10ca94feef7f19 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 29 Apr 2022 16:11:49 +0900 Subject: [PATCH] Update std.js --- lib/std.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/std.js b/lib/std.js index eb0ae8e..3d8a4d8 100644 --- a/lib/std.js +++ b/lib/std.js @@ -251,6 +251,20 @@ function addslashes(s) { ; }; +function cartesian(arr) { + return arr.reduce(function(a, b) { + return a.map(function(x) { + return b.map(function(y) { + return x.concat([y]); + }) + }).reduce(function(a, b) { + return a.concat(b); + }, []); + }, [ + [] + ]); +}; + ///////////////////////////////////////////////////////////////////////////////// // Private APIs / Utility functions ///////////////////////////////////////////////////////////////////////////////// @@ -371,4 +385,6 @@ exports.require = global.require; exports.Event = StdEvent; exports.EventableObject = StdEventableObject; + exports.alert = alert; +exports.cartesian = cartesian;