Paste: swizec-funct

Author: refaktor
Mode: javascript
Date: Fri, 7 Oct 2011 16:19:04
Plain Text |
var f = function(d, a, r) {
            var l = d.length, x = Math.floor(a/l), y=a%l;
            return a >= l*l-1 ? r : f(d, a+1, r.concat( x<y ? [[d[x],d[y]]] : [] ));
};
f([1,2,3,4], 0, []);

JSON.stringify(  f([1,2,3,4], 0, [])  )
"[[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]"

New Annotation

Summary:
Author:
Mode:
Body: