was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 14  →  ?path2? @ 15
/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";
this.forEach((s) => {
(Array.isArray(this) ? this : [ 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";
q.forEach((s) => {
(Array.isArray(q) ? q : [ q ]).forEach((s) => {
var m = false;
for(i = 0; i < c.length; i += 2) {
if(!c[i](s))