was.js
/trunk/lib/lambda/aggregators.js |
@@ -4,11 +4,11 @@ |
/* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */ |
/*************************************************************************/ |
if (!Array.prototype.switch) { |
Array.prototype.switch = function(d, ...c) { |
Array.prototype.switch = function(d, c) { |
if(c.length % 2 != 0) |
throw "Pairs of predicates expected for cases"; |
|
(Array.isArray(this) ? this : [ this ]).forEach((s) => { |
this.forEach((s) => { |
var m = false; |
for(i = 0; i < c.length; i += 2) { |
if(!c[i](s)) |
@@ -30,11 +30,11 @@ |
/* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */ |
/*************************************************************************/ |
$.extend({ |
switch: function(q, d, ...c) { |
switch: function(q, d, c) { |
if(c.length % 2 != 0) |
throw "Pairs of predicates expected for cases"; |
|
(Array.isArray(q) ? q : [ q ]).forEach((s) => { |
q.forEach((s) => { |
var m = false; |
for(i = 0; i < c.length; i += 2) { |
if(!c[i](s)) |