|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716 |
- // Generated by LiveScript 1.6.0
- var each, map, compact, filter, reject, remove, 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;
- each = curry$(function(f, xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- f(x);
- }
- return xs;
- });
- map = curry$(function(f, xs){
- var i$, len$, x, results$ = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- results$.push(f(x));
- }
- return results$;
- });
- compact = function(xs){
- var i$, len$, x, results$ = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (x) {
- results$.push(x);
- }
- }
- return results$;
- };
- filter = curry$(function(f, xs){
- var i$, len$, x, results$ = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (f(x)) {
- results$.push(x);
- }
- }
- return results$;
- });
- reject = curry$(function(f, xs){
- var i$, len$, x, results$ = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (!f(x)) {
- results$.push(x);
- }
- }
- return results$;
- });
- remove = curry$(function(el, xs){
- var i, x$;
- i = elemIndex(el, xs);
- x$ = xs.slice();
- if (i != null) {
- x$.splice(i, 1);
- }
- return x$;
- });
- partition = curry$(function(f, xs){
- var passed, failed, i$, len$, x;
- passed = [];
- failed = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- (f(x) ? passed : failed).push(x);
- }
- return [passed, failed];
- });
- find = curry$(function(f, xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (f(x)) {
- return x;
- }
- }
- });
- head = first = function(xs){
- return xs[0];
- };
- tail = function(xs){
- if (!xs.length) {
- return;
- }
- return xs.slice(1);
- };
- last = function(xs){
- return xs[xs.length - 1];
- };
- initial = function(xs){
- if (!xs.length) {
- return;
- }
- return xs.slice(0, -1);
- };
- empty = function(xs){
- return !xs.length;
- };
- reverse = function(xs){
- return xs.concat().reverse();
- };
- unique = function(xs){
- var result, i$, len$, x;
- result = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (!in$(x, result)) {
- result.push(x);
- }
- }
- return result;
- };
- uniqueBy = curry$(function(f, xs){
- var seen, i$, len$, x, val, results$ = [];
- seen = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- val = f(x);
- if (in$(val, seen)) {
- continue;
- }
- seen.push(val);
- results$.push(x);
- }
- return results$;
- });
- fold = foldl = curry$(function(f, memo, xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- memo = f(memo, x);
- }
- return memo;
- });
- fold1 = foldl1 = curry$(function(f, xs){
- return fold(f, xs[0], xs.slice(1));
- });
- foldr = curry$(function(f, memo, xs){
- var i$, x;
- for (i$ = xs.length - 1; i$ >= 0; --i$) {
- x = xs[i$];
- memo = f(x, memo);
- }
- return memo;
- });
- foldr1 = curry$(function(f, xs){
- return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
- });
- unfoldr = curry$(function(f, b){
- var result, x, that;
- result = [];
- x = b;
- while ((that = f(x)) != null) {
- result.push(that[0]);
- x = that[1];
- }
- return result;
- });
- concat = function(xss){
- return [].concat.apply([], xss);
- };
- concatMap = curry$(function(f, xs){
- var x;
- return [].concat.apply([], (function(){
- var i$, ref$, len$, results$ = [];
- for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
- x = ref$[i$];
- results$.push(f(x));
- }
- return results$;
- }()));
- });
- flatten = function(xs){
- var x;
- return [].concat.apply([], (function(){
- var i$, ref$, len$, results$ = [];
- for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
- x = ref$[i$];
- if (toString$.call(x).slice(8, -1) === 'Array') {
- results$.push(flatten(x));
- } else {
- results$.push(x);
- }
- }
- return results$;
- }()));
- };
- difference = function(xs){
- var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
- res$ = [];
- for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
- res$.push(arguments[i$]);
- }
- yss = res$;
- results = [];
- outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
- ys = yss[j$];
- if (in$(x, ys)) {
- continue outer;
- }
- }
- results.push(x);
- }
- return results;
- };
- intersection = function(xs){
- var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
- res$ = [];
- for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
- res$.push(arguments[i$]);
- }
- yss = res$;
- results = [];
- outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
- ys = yss[j$];
- if (!in$(x, ys)) {
- continue outer;
- }
- }
- results.push(x);
- }
- return results;
- };
- union = function(){
- var xss, res$, i$, to$, results, len$, xs, j$, len1$, x;
- res$ = [];
- for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
- res$.push(arguments[i$]);
- }
- xss = res$;
- results = [];
- for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
- xs = xss[i$];
- for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
- x = xs[j$];
- if (!in$(x, results)) {
- results.push(x);
- }
- }
- }
- return results;
- };
- countBy = curry$(function(f, xs){
- var results, i$, len$, x, key;
- results = {};
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- key = f(x);
- if (key in results) {
- results[key] += 1;
- } else {
- results[key] = 1;
- }
- }
- return results;
- });
- groupBy = curry$(function(f, xs){
- var results, i$, len$, x, key;
- results = {};
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- key = f(x);
- if (key in results) {
- results[key].push(x);
- } else {
- results[key] = [x];
- }
- }
- return results;
- });
- andList = function(xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (!x) {
- return false;
- }
- }
- return true;
- };
- orList = function(xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (x) {
- return true;
- }
- }
- return false;
- };
- any = curry$(function(f, xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (f(x)) {
- return true;
- }
- }
- return false;
- });
- all = curry$(function(f, xs){
- var i$, len$, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- if (!f(x)) {
- return false;
- }
- }
- return true;
- });
- sort = function(xs){
- return xs.concat().sort(function(x, y){
- if (x > y) {
- return 1;
- } else if (x < y) {
- return -1;
- } else {
- return 0;
- }
- });
- };
- sortWith = curry$(function(f, xs){
- return xs.concat().sort(f);
- });
- sortBy = curry$(function(f, xs){
- return xs.concat().sort(function(x, y){
- if (f(x) > f(y)) {
- return 1;
- } else if (f(x) < f(y)) {
- return -1;
- } else {
- return 0;
- }
- });
- });
- sum = function(xs){
- var result, i$, len$, x;
- result = 0;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- result += x;
- }
- return result;
- };
- product = function(xs){
- var result, i$, len$, x;
- result = 1;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- result *= x;
- }
- return result;
- };
- mean = average = function(xs){
- var sum, i$, len$, x;
- sum = 0;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- x = xs[i$];
- sum += x;
- }
- return sum / xs.length;
- };
- maximum = function(xs){
- var max, i$, ref$, len$, x;
- max = xs[0];
- for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
- x = ref$[i$];
- if (x > max) {
- max = x;
- }
- }
- return max;
- };
- minimum = function(xs){
- var min, i$, ref$, len$, x;
- min = xs[0];
- for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
- x = ref$[i$];
- if (x < min) {
- min = x;
- }
- }
- return min;
- };
- maximumBy = curry$(function(f, xs){
- var max, i$, ref$, len$, x;
- max = xs[0];
- for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
- x = ref$[i$];
- if (f(x) > f(max)) {
- max = x;
- }
- }
- return max;
- });
- minimumBy = curry$(function(f, xs){
- var min, i$, ref$, len$, x;
- min = xs[0];
- for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
- x = ref$[i$];
- if (f(x) < f(min)) {
- min = x;
- }
- }
- return min;
- });
- scan = scanl = curry$(function(f, memo, xs){
- var last, x;
- last = memo;
- return [memo].concat((function(){
- var i$, ref$, len$, results$ = [];
- for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
- x = ref$[i$];
- results$.push(last = f(last, x));
- }
- return results$;
- }()));
- });
- scan1 = scanl1 = curry$(function(f, xs){
- if (!xs.length) {
- return;
- }
- return scan(f, xs[0], xs.slice(1));
- });
- scanr = curry$(function(f, memo, xs){
- xs = xs.concat().reverse();
- return scan(f, memo, xs).reverse();
- });
- scanr1 = curry$(function(f, xs){
- if (!xs.length) {
- return;
- }
- xs = xs.concat().reverse();
- return scan(f, xs[0], xs.slice(1)).reverse();
- });
- slice = curry$(function(x, y, xs){
- return xs.slice(x, y);
- });
- take = curry$(function(n, xs){
- if (n <= 0) {
- return xs.slice(0, 0);
- } else {
- return xs.slice(0, n);
- }
- });
- drop = curry$(function(n, xs){
- if (n <= 0) {
- return xs;
- } else {
- return xs.slice(n);
- }
- });
- splitAt = curry$(function(n, xs){
- return [take(n, xs), drop(n, xs)];
- });
- takeWhile = curry$(function(p, xs){
- var len, i;
- len = xs.length;
- if (!len) {
- return xs;
- }
- i = 0;
- while (i < len && p(xs[i])) {
- i += 1;
- }
- return xs.slice(0, i);
- });
- dropWhile = curry$(function(p, xs){
- var len, i;
- len = xs.length;
- if (!len) {
- return xs;
- }
- i = 0;
- while (i < len && p(xs[i])) {
- i += 1;
- }
- return xs.slice(i);
- });
- span = curry$(function(p, xs){
- return [takeWhile(p, xs), dropWhile(p, xs)];
- });
- breakList = curry$(function(p, xs){
- return span(compose$(p, not$), xs);
- });
- zip = curry$(function(xs, ys){
- var result, len, i$, len$, i, x;
- result = [];
- len = ys.length;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- i = i$;
- x = xs[i$];
- if (i === len) {
- break;
- }
- result.push([x, ys[i]]);
- }
- return result;
- });
- zipWith = curry$(function(f, xs, ys){
- var result, len, i$, len$, i, x;
- result = [];
- len = ys.length;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- i = i$;
- x = xs[i$];
- if (i === len) {
- break;
- }
- result.push(f(x, ys[i]));
- }
- return result;
- });
- zipAll = function(){
- var xss, res$, i$, to$, minLength, len$, xs, ref$, i, lresult$, j$, results$ = [];
- res$ = [];
- for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
- res$.push(arguments[i$]);
- }
- xss = res$;
- minLength = undefined;
- for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
- xs = xss[i$];
- minLength <= (ref$ = xs.length) || (minLength = ref$);
- }
- for (i$ = 0; i$ < minLength; ++i$) {
- i = i$;
- lresult$ = [];
- for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
- xs = xss[j$];
- lresult$.push(xs[i]);
- }
- results$.push(lresult$);
- }
- return results$;
- };
- zipAllWith = function(f){
- var xss, res$, i$, to$, minLength, len$, xs, ref$, i, results$ = [];
- res$ = [];
- for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
- res$.push(arguments[i$]);
- }
- xss = res$;
- minLength = undefined;
- for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
- xs = xss[i$];
- minLength <= (ref$ = xs.length) || (minLength = ref$);
- }
- for (i$ = 0; i$ < minLength; ++i$) {
- i = i$;
- results$.push(f.apply(null, (fn$())));
- }
- return results$;
- function fn$(){
- var i$, ref$, len$, results$ = [];
- for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) {
- xs = ref$[i$];
- results$.push(xs[i]);
- }
- return results$;
- }
- };
- at = curry$(function(n, xs){
- if (n < 0) {
- return xs[xs.length + n];
- } else {
- return xs[n];
- }
- });
- elemIndex = curry$(function(el, xs){
- var i$, len$, i, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- i = i$;
- x = xs[i$];
- if (x === el) {
- return i;
- }
- }
- });
- elemIndices = curry$(function(el, xs){
- var i$, len$, i, x, results$ = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- i = i$;
- x = xs[i$];
- if (x === el) {
- results$.push(i);
- }
- }
- return results$;
- });
- findIndex = curry$(function(f, xs){
- var i$, len$, i, x;
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- i = i$;
- x = xs[i$];
- if (f(x)) {
- return i;
- }
- }
- });
- findIndices = curry$(function(f, xs){
- var i$, len$, i, x, results$ = [];
- for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
- i = i$;
- x = xs[i$];
- if (f(x)) {
- results$.push(i);
- }
- }
- return results$;
- });
- module.exports = {
- each: each,
- map: map,
- filter: filter,
- compact: compact,
- reject: reject,
- remove: remove,
- partition: partition,
- find: find,
- head: head,
- first: first,
- tail: tail,
- last: last,
- initial: initial,
- empty: empty,
- reverse: reverse,
- difference: difference,
- intersection: intersection,
- union: union,
- countBy: countBy,
- groupBy: groupBy,
- fold: fold,
- fold1: fold1,
- foldl: foldl,
- foldl1: foldl1,
- foldr: foldr,
- foldr1: foldr1,
- unfoldr: unfoldr,
- andList: andList,
- orList: orList,
- any: any,
- all: all,
- unique: unique,
- uniqueBy: uniqueBy,
- sort: sort,
- sortWith: sortWith,
- sortBy: sortBy,
- sum: sum,
- product: product,
- mean: mean,
- average: average,
- concat: concat,
- concatMap: concatMap,
- flatten: flatten,
- maximum: maximum,
- minimum: minimum,
- maximumBy: maximumBy,
- minimumBy: minimumBy,
- scan: scan,
- scan1: scan1,
- scanl: scanl,
- scanl1: scanl1,
- scanr: scanr,
- scanr1: scanr1,
- slice: slice,
- take: take,
- drop: drop,
- splitAt: splitAt,
- takeWhile: takeWhile,
- dropWhile: dropWhile,
- span: span,
- breakList: breakList,
- zip: zip,
- zipWith: zipWith,
- zipAll: zipAll,
- zipAllWith: zipAllWith,
- at: at,
- elemIndex: elemIndex,
- elemIndices: elemIndices,
- findIndex: findIndex,
- findIndices: findIndices
- };
- function curry$(f, bound){
- var context,
- _curry = function(args) {
- return f.length > 1 ? function(){
- var params = args ? args.concat() : [];
- context = bound ? context || this : this;
- return params.push.apply(params, arguments) <
- f.length && arguments.length ?
- _curry.call(context, params) : f.apply(context, params);
- } : f;
- };
- return _curry();
- }
- function in$(x, xs){
- var i = -1, l = xs.length >>> 0;
- while (++i < l) if (x === xs[i]) return true;
- return false;
- }
- function compose$() {
- var functions = arguments;
- return function() {
- var i, result;
- result = functions[0].apply(this, arguments);
- for (i = 1; i < functions.length; ++i) {
- result = functions[i](result);
- }
- return result;
- };
- }
- function not$(x){ return !x; }
|