1 // Generated by LiveScript 1.2.0
2 var each, map, compact, filter, reject, partition, find, head, first, tail, last, initial, empty, reverse, unique, uniqueBy, fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, concat, concatMap, flatten, difference, intersection, union, countBy, groupBy, andList, orList, any, all, sort, sortWith, sortBy, sum, product, mean, average, maximum, minimum, maximumBy, minimumBy, scan, scanl, scan1, scanl1, scanr, scanr1, slice, take, drop, splitAt, takeWhile, dropWhile, span, breakList, zip, zipWith, zipAll, zipAllWith, at, elemIndex, elemIndices, findIndex, findIndices, toString$ = {}.toString, slice$ = [].slice;
3 each = curry$(function(f, xs){
5 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
11 map = curry$(function(f, xs){
12 var i$, len$, x, results$ = [];
13 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
19 compact = function(xs){
20 var i$, len$, x, results$ = [];
21 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
29 filter = curry$(function(f, xs){
30 var i$, len$, x, results$ = [];
31 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
39 reject = curry$(function(f, xs){
40 var i$, len$, x, results$ = [];
41 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
49 partition = curry$(function(f, xs){
50 var passed, failed, i$, len$, x;
53 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
55 (f(x) ? passed : failed).push(x);
57 return [passed, failed];
59 find = curry$(function(f, xs){
61 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
68 head = first = function(xs){
78 return xs[xs.length - 1];
80 initial = function(xs){
84 return xs.slice(0, -1);
89 reverse = function(xs){
90 return xs.concat().reverse();
92 unique = function(xs){
93 var result, i$, len$, x;
95 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
97 if (!in$(x, result)) {
103 uniqueBy = curry$(function(f, xs){
104 var seen, i$, len$, x, val, results$ = [];
106 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
109 if (in$(val, seen)) {
117 fold = foldl = curry$(function(f, memo, xs){
119 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
125 fold1 = foldl1 = curry$(function(f, xs){
126 return fold(f, xs[0], xs.slice(1));
128 foldr = curry$(function(f, memo, xs){
130 for (i$ = xs.length - 1; i$ >= 0; --i$) {
136 foldr1 = curry$(function(f, xs){
137 return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
139 unfoldr = curry$(function(f, b){
143 while ((that = f(x)) != null) {
144 result.push(that[0]);
149 concat = function(xss){
150 return [].concat.apply([], xss);
152 concatMap = curry$(function(f, xs){
154 return [].concat.apply([], (function(){
155 var i$, ref$, len$, results$ = [];
156 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
163 flatten = function(xs){
165 return [].concat.apply([], (function(){
166 var i$, ref$, len$, results$ = [];
167 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
169 if (toString$.call(x).slice(8, -1) === 'Array') {
170 results$.push(flatten(x));
178 difference = function(xs){
179 var yss, results, i$, len$, x, j$, len1$, ys;
180 yss = slice$.call(arguments, 1);
182 outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
184 for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
194 intersection = function(xs){
195 var yss, results, i$, len$, x, j$, len1$, ys;
196 yss = slice$.call(arguments, 1);
198 outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
200 for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
211 var xss, results, i$, len$, xs, j$, len1$, x;
212 xss = slice$.call(arguments);
214 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
216 for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
218 if (!in$(x, results)) {
225 countBy = curry$(function(f, xs){
226 var results, i$, len$, x, key;
228 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
231 if (key in results) {
239 groupBy = curry$(function(f, xs){
240 var results, i$, len$, x, key;
242 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
245 if (key in results) {
246 results[key].push(x);
253 andList = function(xs){
255 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
263 orList = function(xs){
265 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
273 any = curry$(function(f, xs){
275 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
283 all = curry$(function(f, xs){
285 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
294 return xs.concat().sort(function(x, y){
304 sortWith = curry$(function(f, xs){
305 return xs.concat().sort(f);
307 sortBy = curry$(function(f, xs){
308 return xs.concat().sort(function(x, y){
311 } else if (f(x) < f(y)) {
319 var result, i$, len$, x;
321 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
327 product = function(xs){
328 var result, i$, len$, x;
330 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
336 mean = average = function(xs){
337 var sum, i$, len$, x;
339 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
343 return sum / xs.length;
345 maximum = function(xs){
346 var max, i$, ref$, len$, x;
348 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
356 minimum = function(xs){
357 var min, i$, ref$, len$, x;
359 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
367 maximumBy = curry$(function(f, xs){
368 var max, i$, ref$, len$, x;
370 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
378 minimumBy = curry$(function(f, xs){
379 var min, i$, ref$, len$, x;
381 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
389 scan = scanl = curry$(function(f, memo, xs){
392 return [memo].concat((function(){
393 var i$, ref$, len$, results$ = [];
394 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
396 results$.push(last = f(last, x));
401 scan1 = scanl1 = curry$(function(f, xs){
405 return scan(f, xs[0], xs.slice(1));
407 scanr = curry$(function(f, memo, xs){
408 xs = xs.concat().reverse();
409 return scan(f, memo, xs).reverse();
411 scanr1 = curry$(function(f, xs){
415 xs = xs.concat().reverse();
416 return scan(f, xs[0], xs.slice(1)).reverse();
418 slice = curry$(function(x, y, xs){
419 return xs.slice(x, y);
421 take = curry$(function(n, xs){
423 return xs.slice(0, 0);
425 return xs.slice(0, n);
428 drop = curry$(function(n, xs){
435 splitAt = curry$(function(n, xs){
436 return [take(n, xs), drop(n, xs)];
438 takeWhile = curry$(function(p, xs){
445 while (i < len && p(xs[i])) {
448 return xs.slice(0, i);
450 dropWhile = curry$(function(p, xs){
457 while (i < len && p(xs[i])) {
462 span = curry$(function(p, xs){
463 return [takeWhile(p, xs), dropWhile(p, xs)];
465 breakList = curry$(function(p, xs){
466 return span(function(){
467 return not$(p.apply(this, arguments));
470 zip = curry$(function(xs, ys){
471 var result, len, i$, len$, i, x;
474 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
480 result.push([x, ys[i]]);
484 zipWith = curry$(function(f, xs, ys){
485 var result, len, i$, len$, i, x;
488 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
494 result.push(f(x, ys[i]));
499 var xss, minLength, i$, len$, xs, ref$, i, lresult$, j$, results$ = [];
500 xss = slice$.call(arguments);
502 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
504 minLength <= (ref$ = xs.length) || (minLength = ref$);
506 for (i$ = 0; i$ < minLength; ++i$) {
509 for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
511 lresult$.push(xs[i]);
513 results$.push(lresult$);
517 zipAllWith = function(f){
518 var xss, minLength, i$, len$, xs, ref$, i, results$ = [];
519 xss = slice$.call(arguments, 1);
521 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
523 minLength <= (ref$ = xs.length) || (minLength = ref$);
525 for (i$ = 0; i$ < minLength; ++i$) {
527 results$.push(f.apply(null, (fn$())));
531 var i$, ref$, len$, results$ = [];
532 for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) {
534 results$.push(xs[i]);
539 at = curry$(function(n, xs){
541 return xs[xs.length + n];
546 elemIndex = curry$(function(el, xs){
548 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
556 elemIndices = curry$(function(el, xs){
557 var i$, len$, i, x, results$ = [];
558 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
567 findIndex = curry$(function(f, xs){
569 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
577 findIndices = curry$(function(f, xs){
578 var i$, len$, i, x, results$ = [];
579 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
594 partition: partition,
603 difference: difference,
604 intersection: intersection,
629 concatMap: concatMap,
633 maximumBy: maximumBy,
634 minimumBy: minimumBy,
645 takeWhile: takeWhile,
646 dropWhile: dropWhile,
648 breakList: breakList,
652 zipAllWith: zipAllWith,
654 elemIndex: elemIndex,
655 elemIndices: elemIndices,
656 findIndex: findIndex,
657 findIndices: findIndices
659 function curry$(f, bound){
661 _curry = function(args) {
662 return f.length > 1 ? function(){
663 var params = args ? args.concat() : [];
664 context = bound ? context || this : this;
665 return params.push.apply(params, arguments) <
666 f.length && arguments.length ?
667 _curry.call(context, params) : f.apply(context, params);
673 var i = -1, l = xs.length >>> 0;
674 while (++i < l) if (x === xs[i]) return true;
677 function not$(x){ return !x; }