Repository: gkz/prelude-ls
Branch: master
Commit: 4457c5cf834b
Files: 30
Total size: 130.9 KB
Directory structure:
gitextract_3gmtmqye/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── Makefile
├── README.md
├── browser/
│ ├── prelude-browser-min.js
│ └── prelude-browser.js
├── lib/
│ ├── Func.js
│ ├── List.js
│ ├── Num.js
│ ├── Obj.js
│ ├── Str.js
│ └── index.js
├── package.json
├── package.json.ls
├── preroll.ls
├── src/
│ ├── Func.ls
│ ├── List.ls
│ ├── Num.ls
│ ├── Obj.ls
│ ├── Str.ls
│ └── index.ls
└── test/
├── Func.ls
├── List.ls
├── Num.ls
├── Obj.ls
├── Str.ls
├── browser.html
└── index.ls
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.swp
node_modules
coverage
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- 12
================================================
FILE: CHANGELOG.md
================================================
# 1.2.1
- fix version
# 1.2.0
- add `List.remove`
- build with LiveScript 1.6.0
- update dependencies
- remove coverage calculation
# 1.1.2
- add `Func.memoize`
- fix `zip-all` and `zip-with-all` corner case (no input)
- build with LiveScript 1.4.0
# 1.1.1
- curry `unique-by`, `minimum-by`
# 1.1.0
- added `List` functions: `maximum-by`, `minimum-by`, `unique-by`
- added `List` functions: `at`, `elem-index`, `elem-indices`, `find-index`, `find-indices`
- added `Str` functions: `capitalize`, `camelize`, `dasherize`
- added `Func` function: `over` - eg. ``same-length = (==) `over` (.length)``
- exported `Str.repeat` through main `prelude` object
- fixed definition of `foldr` and `foldr1`, the new correct definition is backwards incompatible with the old, incorrect one
- fixed issue with `fix`
- improved code coverage
# 1.0.3
- build browser versions
# 1.0.2
- bug fix for `flatten` - slight change with bug fix, flattens arrays only, not array-like objects
# 1.0.1
- bug fixes for `drop-while` and `take-while`
# 1.0.0
* massive update - separated functions into separate modules
* functions do not accept multiple types anymore - use different versions in their respective modules in some cases (eg. `Obj.map`), or use `chars` or `values` in other cases to transform into a list
* objects are no longer transformed into functions, simply use `(obj.)` in LiveScript to do that
* browser version now using browserify - use `prelude = require('prelude-ls')`
* added `compact`, `split`, `flatten`, `difference`, `intersection`, `union`, `count-by`, `group-by`, `chars`, `unchars`, `apply`
* added `lists-to-obj` which takes a list of keys and list of values and zips them up into an object, and the converse `obj-to-lists`
* added `pairs-to-obj` which takes a list of pairs (2 element lists) and creates an object, and the converse `obj-to-pairs`
* removed `cons`, `append` - use the concat operator
* removed `compose` - use the compose operator
* removed `obj-to-func` - use partially applied access (eg. `(obj.)`)
* removed `length` - use `(.length)`
* `sort-by` renamed to `sort-with`
* added new `sort-by`
* removed `compare` - just use the new `sort-by`
* `break-it` renamed `break-list`, (`Str.break-str` for the string version)
* added `Str.repeat` which creates a new string by repeating the input n times
* `unfold` as alias to `unfoldr` is no longer used
* fixed up style and compiled with LiveScript 1.1.1
* use Make instead of Slake
* greatly improved tests
# 0.6.0
* fixed various bugs
* added `fix`, a fixpoint (Y combinator) for anonymous recursive functions
* added `unfoldr` (alias `unfold`)
* calling `replicate` with a string now returns a list of strings
* removed `partial`, just use native partial application in LiveScript using the `_` placeholder, or currying
* added `sort`, `sortBy`, and `compare`
# 0.5.0
* removed `lookup` - use (.prop)
* removed `call` - use (.func arg1, arg2)
* removed `pluck` - use map (.prop), xs
* fixed buys wtih `head` and `last`
* added non-minifed browser version, as `prelude-browser.js`
* renamed `prelude-min.js` to `prelude-browser-min.js`
* renamed `zip` to `zipAll`
* renamed `zipWith` to `zipAllWith`
* added `zip`, a curried zip that takes only two arguments
* added `zipWith`, a curried zipWith that takes only two arguments
# 0.4.0
* added `parition` function
* added `curry` function
* removed `elem` function (use `in`)
* removed `notElem` function (use `not in`)
# 0.3.0
* added `listToObject`
* added `unique`
* added `objToFunc`
* added support for using strings in map and the like
* added support for using objects in map and the like
* added ability to use objects instead of functions in certain cases
* removed `error` (just use throw)
* added `tau` constant
* added `join`
* added `values`
* added `keys`
* added `partial`
* renamed `log` to `ln`
* added alias to `head`: `first`
* added `installPrelude` helper
# 0.2.0
* removed functions that simply warp operators as you can now use operators as functions in LiveScript
* `min/max` are now curried and take only 2 arguments
* added `call`
# 0.1.0
* initial public release
================================================
FILE: LICENSE
================================================
Copyright (c) George Zahariev
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: Makefile
================================================
default: all
SRC = $(shell find src -name "*.ls" -type f | sort)
LIB = $(SRC:src/%.ls=lib/%.js)
LS = node_modules/livescript
LSC = node_modules/.bin/lsc
BROWSERIFY = node_modules/.bin/browserify
UGLIFYJS = node_modules/.bin/uglifyjs
MOCHA = node_modules/.bin/mocha
lib:
mkdir -p lib/
lib/%.js: src/%.ls lib
$(LSC) --output lib --bare --compile "$<"
browser:
mkdir browser/
prelude-browser.js: $(LIB) browser preroll.ls
{ $(LSC) ./preroll.ls ; $(BROWSERIFY) -r ./lib/index.js:prelude-ls ; } > browser/prelude-browser.js
prelude-browser-min.js: browser/prelude-browser.js
$(UGLIFYJS) browser/prelude-browser.js --mangle --comments "all" > browser/prelude-browser-min.js
package.json: package.json.ls
$(LSC) --compile package.json.ls
.PHONY: build build-browser test dev-install loc clean
all: build
build: $(LIB) package.json
build-browser: prelude-browser.js prelude-browser-min.js
test: build
$(MOCHA) --ui tdd --require livescript "test/**/*.ls"
dev-install: package.json
npm install .
loc:
wc --lines src/*
clean:
rm -f ./*.js
rm -rf lib
rm -rf browser
rm -f package.json
================================================
FILE: README.md
================================================
# prelude.ls [](https://travis-ci.org/gkz/prelude-ls)
is a functionally oriented utility library. It is powerful and flexible. Almost all of its functions are curried. It is written in, and is the recommended base library for, <a href="http://livescript.net">LiveScript</a>.
See **[the prelude.ls site](http://preludels.com)** for examples, a reference, and more.
You can install via npm `npm install prelude-ls`
### Development
`make test` to test
`make build` to build `lib` from `src`
`make build-browser` to build browser versions
================================================
FILE: browser/prelude-browser-min.js
================================================
// Generated by LiveScript 1.6.0
// prelude.ls 1.2.1
// Copyright (c) George Zahariev
// Released under the MIT License
// https://raw.githubusercontent.com/gkz/prelude-ls/master/LICENSE
require=function(){function l(u,o,a){function f(t,n){if(!o[t]){if(!u[t]){var r="function"==typeof require&&require;if(!n&&r)return r(t,!0);if(c)return c(t,!0);var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}var i=o[t]={exports:{}};u[t][0].call(i.exports,function(n){var r=u[t][1][n];return f(r||n)},i,i.exports,l,u,o,a)}return o[t].exports}for(var c="function"==typeof require&&require,n=0;n<a.length;n++)f(a[n]);return f}return l}()({1:[function(n,r,t){
// Generated by LiveScript 1.6.0
var e,i,u,o,a,f,c={}.toString;e=l(function(n,r){return n.apply(null,r)});i=function(n){return l(n)};u=l(function(n,r,t){return n(t,r)});o=function(r){return function(n){return function(){return r(n(n)).apply(null,arguments)}}(function(n){return function(){return r(n(n)).apply(null,arguments)}})};a=l(function(n,r,t,e){return n(r(t),r(e))});f=function(o){var a;a={};return function(){var i,n,r,t,e,u;n=[];for(r=0,t=arguments.length;r<t;++r){n.push(arguments[r])}i=n;e=function(){var n,r,t,e=[];for(n=0,t=(r=i).length;n<t;++n){u=r[n];e.push(u+c.call(u).slice(8,-1))}return e}().join("");return a[e]=e in a?a[e]:o.apply(null,i)}};r.exports={curry:i,flip:u,fix:o,apply:e,over:a,memoize:f};function l(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)<t.length&&arguments.length?u.call(i,n):t.apply(i,n)}:t};return u()}},{}],2:[function(n,r,t){
// Generated by LiveScript 1.6.0
var e,i,u,o,a,f,c,l,s,h,p,v,g,d,m,y,j,x,b,M,z,k,w,L,W,q,B,I,A,T,O,N,S,C,F,P,U,E,Z,_,D,R,V,G,H,J,K,Q,X,Y,$,nn,rn,tn,en,un,on,an,fn,cn,ln,sn,hn,pn,vn,gn,dn,mn,yn,jn,xn={}.toString;e=bn(function(n,r){var t,e,i;for(t=0,e=r.length;t<e;++t){i=r[t];n(i)}return r});i=bn(function(n,r){var t,e,i,u=[];for(t=0,e=r.length;t<e;++t){i=r[t];u.push(n(i))}return u});u=function(n){var r,t,e,i=[];for(r=0,t=n.length;r<t;++r){e=n[r];if(e){i.push(e)}}return i};o=bn(function(n,r){var t,e,i,u=[];for(t=0,e=r.length;t<e;++t){i=r[t];if(n(i)){u.push(i)}}return u});a=bn(function(n,r){var t,e,i,u=[];for(t=0,e=r.length;t<e;++t){i=r[t];if(!n(i)){u.push(i)}}return u});f=bn(function(n,r){var t,e;t=dn(n,r);e=r.slice();if(t!=null){e.splice(t,1)}return e});c=bn(function(n,r){var t,e,i,u,o;t=[];e=[];for(i=0,u=r.length;i<u;++i){o=r[i];(n(o)?t:e).push(o)}return[t,e]});l=bn(function(n,r){var t,e,i;for(t=0,e=r.length;t<e;++t){i=r[t];if(n(i)){return i}}});s=h=function(n){return n[0]};p=function(n){if(!n.length){return}return n.slice(1)};v=function(n){return n[n.length-1]};g=function(n){if(!n.length){return}return n.slice(0,-1)};d=function(n){return!n.length};m=function(n){return n.concat().reverse()};y=function(n){var r,t,e,i;r=[];for(t=0,e=n.length;t<e;++t){i=n[t];if(!Mn(i,r)){r.push(i)}}return r};j=bn(function(n,r){var t,e,i,u,o,a=[];t=[];for(e=0,i=r.length;e<i;++e){u=r[e];o=n(u);if(Mn(o,t)){continue}t.push(o);a.push(u)}return a});x=b=bn(function(n,r,t){var e,i,u;for(e=0,i=t.length;e<i;++e){u=t[e];r=n(r,u)}return r});M=z=bn(function(n,r){return x(n,r[0],r.slice(1))});k=bn(function(n,r,t){var e,i;for(e=t.length-1;e>=0;--e){i=t[e];r=n(i,r)}return r});w=bn(function(n,r){return k(n,r[r.length-1],r.slice(0,-1))});L=bn(function(n,r){var t,e,i;t=[];e=r;while((i=n(e))!=null){t.push(i[0]);e=i[1]}return t});W=function(n){return[].concat.apply([],n)};q=bn(function(i,u){var o;return[].concat.apply([],function(){var n,r,t,e=[];for(n=0,t=(r=u).length;n<t;++n){o=r[n];e.push(i(o))}return e}())});B=function(i){var u;return[].concat.apply([],function(){var n,r,t,e=[];for(n=0,t=(r=i).length;n<t;++n){u=r[n];if(xn.call(u).slice(8,-1)==="Array"){e.push(B(u))}else{e.push(u)}}return e}())};I=function(n){var r,t,e,i,u,o,a,f,c,l;t=[];for(e=1,i=arguments.length;e<i;++e){t.push(arguments[e])}r=t;u=[];n:for(e=0,o=n.length;e<o;++e){a=n[e];for(f=0,c=r.length;f<c;++f){l=r[f];if(Mn(a,l)){continue n}}u.push(a)}return u};A=function(n){var r,t,e,i,u,o,a,f,c,l;t=[];for(e=1,i=arguments.length;e<i;++e){t.push(arguments[e])}r=t;u=[];n:for(e=0,o=n.length;e<o;++e){a=n[e];for(f=0,c=r.length;f<c;++f){l=r[f];if(!Mn(a,l)){continue n}}u.push(a)}return u};T=function(){var n,r,t,e,i,u,o,a,f,c;r=[];for(t=0,e=arguments.length;t<e;++t){r.push(arguments[t])}n=r;i=[];for(t=0,u=n.length;t<u;++t){o=n[t];for(a=0,f=o.length;a<f;++a){c=o[a];if(!Mn(c,i)){i.push(c)}}}return i};O=bn(function(n,r){var t,e,i,u,o;t={};for(e=0,i=r.length;e<i;++e){u=r[e];o=n(u);if(o in t){t[o]+=1}else{t[o]=1}}return t});N=bn(function(n,r){var t,e,i,u,o;t={};for(e=0,i=r.length;e<i;++e){u=r[e];o=n(u);if(o in t){t[o].push(u)}else{t[o]=[u]}}return t});S=function(n){var r,t,e;for(r=0,t=n.length;r<t;++r){e=n[r];if(!e){return false}}return true};C=function(n){var r,t,e;for(r=0,t=n.length;r<t;++r){e=n[r];if(e){return true}}return false};F=bn(function(n,r){var t,e,i;for(t=0,e=r.length;t<e;++t){i=r[t];if(n(i)){return true}}return false});P=bn(function(n,r){var t,e,i;for(t=0,e=r.length;t<e;++t){i=r[t];if(!n(i)){return false}}return true});U=function(n){return n.concat().sort(function(n,r){if(n>r){return 1}else if(n<r){return-1}else{return 0}})};E=bn(function(n,r){return r.concat().sort(n)});Z=bn(function(t,n){return n.concat().sort(function(n,r){if(t(n)>t(r)){return 1}else if(t(n)<t(r)){return-1}else{return 0}})});_=function(n){var r,t,e,i;r=0;for(t=0,e=n.length;t<e;++t){i=n[t];r+=i}return r};D=function(n){var r,t,e,i;r=1;for(t=0,e=n.length;t<e;++t){i=n[t];r*=i}return r};R=V=function(n){var r,t,e,i;r=0;for(t=0,e=n.length;t<e;++t){i=n[t];r+=i}return r/n.length};G=function(n){var r,t,e,i,u;r=n[0];for(t=0,i=(e=n.slice(1)).length;t<i;++t){u=e[t];if(u>r){r=u}}return r};H=function(n){var r,t,e,i,u;r=n[0];for(t=0,i=(e=n.slice(1)).length;t<i;++t){u=e[t];if(u<r){r=u}}return r};J=bn(function(n,r){var t,e,i,u,o;t=r[0];for(e=0,u=(i=r.slice(1)).length;e<u;++e){o=i[e];if(n(o)>n(t)){t=o}}return t});K=bn(function(n,r){var t,e,i,u,o;t=r[0];for(e=0,u=(i=r.slice(1)).length;e<u;++e){o=i[e];if(n(o)<n(t)){t=o}}return t});Q=X=bn(function(i,n,u){var o,a;o=n;return[n].concat(function(){var n,r,t,e=[];for(n=0,t=(r=u).length;n<t;++n){a=r[n];e.push(o=i(o,a))}return e}())});Y=$=bn(function(n,r){if(!r.length){return}return Q(n,r[0],r.slice(1))});nn=bn(function(n,r,t){t=t.concat().reverse();return Q(n,r,t).reverse()});rn=bn(function(n,r){if(!r.length){return}r=r.concat().reverse();return Q(n,r[0],r.slice(1)).reverse()});tn=bn(function(n,r,t){return t.slice(n,r)});en=bn(function(n,r){if(n<=0){return r.slice(0,0)}else{return r.slice(0,n)}});un=bn(function(n,r){if(n<=0){return r}else{return r.slice(n)}});on=bn(function(n,r){return[en(n,r),un(n,r)]});an=bn(function(n,r){var t,e;t=r.length;if(!t){return r}e=0;while(e<t&&n(r[e])){e+=1}return r.slice(0,e)});fn=bn(function(n,r){var t,e;t=r.length;if(!t){return r}e=0;while(e<t&&n(r[e])){e+=1}return r.slice(e)});cn=bn(function(n,r){return[an(n,r),fn(n,r)]});ln=bn(function(n,r){return cn(zn(n,kn),r)});sn=bn(function(n,r){var t,e,i,u,o,a;t=[];e=r.length;for(i=0,u=n.length;i<u;++i){o=i;a=n[i];if(o===e){break}t.push([a,r[o]])}return t});hn=bn(function(n,r,t){var e,i,u,o,a,f;e=[];i=t.length;for(u=0,o=r.length;u<o;++u){a=u;f=r[u];if(a===i){break}e.push(n(f,t[a]))}return e});pn=function(){var n,r,t,e,i,u,o,a,f,c,l,s=[];r=[];for(t=0,e=arguments.length;t<e;++t){r.push(arguments[t])}n=r;i=undefined;for(t=0,u=n.length;t<u;++t){o=n[t];i<=(a=o.length)||(i=a)}for(t=0;t<i;++t){f=t;c=[];for(l=0,u=n.length;l<u;++l){o=n[l];c.push(o[f])}s.push(c)}return s};vn=function(n){var i,r,t,e,u,o,a,f,c,l=[];r=[];for(t=1,e=arguments.length;t<e;++t){r.push(arguments[t])}i=r;u=undefined;for(t=0,o=i.length;t<o;++t){a=i[t];u<=(f=a.length)||(u=f)}for(t=0;t<u;++t){c=t;l.push(n.apply(null,s()))}return l;function s(){var n,r,t,e=[];for(n=0,t=(r=i).length;n<t;++n){a=r[n];e.push(a[c])}return e}};gn=bn(function(n,r){if(n<0){return r[r.length+n]}else{return r[n]}});dn=bn(function(n,r){var t,e,i,u;for(t=0,e=r.length;t<e;++t){i=t;u=r[t];if(u===n){return i}}});mn=bn(function(n,r){var t,e,i,u,o=[];for(t=0,e=r.length;t<e;++t){i=t;u=r[t];if(u===n){o.push(i)}}return o});yn=bn(function(n,r){var t,e,i,u;for(t=0,e=r.length;t<e;++t){i=t;u=r[t];if(n(u)){return i}}});jn=bn(function(n,r){var t,e,i,u,o=[];for(t=0,e=r.length;t<e;++t){i=t;u=r[t];if(n(u)){o.push(i)}}return o});r.exports={each:e,map:i,filter:o,compact:u,reject:a,remove:f,partition:c,find:l,head:s,first:h,tail:p,last:v,initial:g,empty:d,reverse:m,difference:I,intersection:A,union:T,countBy:O,groupBy:N,fold:x,fold1:M,foldl:b,foldl1:z,foldr:k,foldr1:w,unfoldr:L,andList:S,orList:C,any:F,all:P,unique:y,uniqueBy:j,sort:U,sortWith:E,sortBy:Z,sum:_,product:D,mean:R,average:V,concat:W,concatMap:q,flatten:B,maximum:G,minimum:H,maximumBy:J,minimumBy:K,scan:Q,scan1:Y,scanl:X,scanl1:$,scanr:nn,scanr1:rn,slice:tn,take:en,drop:un,splitAt:on,takeWhile:an,dropWhile:fn,span:cn,breakList:ln,zip:sn,zipWith:hn,zipAll:pn,zipAllWith:vn,at:gn,elemIndex:dn,elemIndices:mn,findIndex:yn,findIndices:jn};function bn(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)<t.length&&arguments.length?u.call(i,n):t.apply(i,n)}:t};return u()}function Mn(n,r){var t=-1,e=r.length>>>0;while(++t<e)if(n===r[t])return true;return false}function zn(){var t=arguments;return function(){var n,r;r=t[0].apply(this,arguments);for(n=1;n<t.length;++n){r=t[n](r)}return r}}function kn(n){return!n}},{}],3:[function(n,r,t){
// Generated by LiveScript 1.6.0
var e,i,u,o,a,f,c,l,s,h,p,v,g,d,m,y,j,x,b,M,z,k,w,L,W,q,B,I,A,T,O,N;e=S(function(n,r){return n>r?n:r});i=S(function(n,r){return n<r?n:r});u=function(n){return-n};o=Math.abs;a=function(n){if(n<0){return-1}else if(n>0){return 1}else{return 0}};f=S(function(n,r){return~~(n/r)});c=S(function(n,r){return n%r});l=S(function(n,r){return Math.floor(n/r)});s=S(function(n,r){var t;return(n%(t=r)+t)%t});h=function(n){return 1/n};p=Math.PI;v=p*2;g=Math.exp;d=Math.sqrt;m=Math.log;y=S(function(n,r){return Math.pow(n,r)});j=Math.sin;x=Math.tan;b=Math.cos;M=Math.asin;z=Math.acos;k=Math.atan;w=S(function(n,r){return Math.atan2(n,r)});L=function(n){return~~n};W=Math.round;q=Math.ceil;B=Math.floor;I=function(n){return n!==n};A=function(n){return n%2===0};T=function(n){return n%2!==0};O=S(function(n,r){var t;n=Math.abs(n);r=Math.abs(r);while(r!==0){t=n%r;n=r;r=t}return n});N=S(function(n,r){return Math.abs(Math.floor(n/O(n,r)*r))});r.exports={max:e,min:i,negate:u,abs:o,signum:a,quot:f,rem:c,div:l,mod:s,recip:h,pi:p,tau:v,exp:g,sqrt:d,ln:m,pow:y,sin:j,tan:x,cos:b,acos:z,asin:M,atan:k,atan2:w,truncate:L,round:W,ceiling:q,floor:B,isItNaN:I,even:A,odd:T,gcd:O,lcm:N};function S(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)<t.length&&arguments.length?u.call(i,n):t.apply(i,n)}:t};return u()}},{}],4:[function(n,r,t){
// Generated by LiveScript 1.6.0
var e,i,u,o,a,f,c,l,s,h,p,v,g,d;e=function(n){var r,t,e=[];for(r in n){t=n[r];e.push(t)}return e};i=function(n){var r,t=[];for(r in n){t.push(r)}return t};u=function(n){var r,t,e,i={};for(r=0,t=n.length;r<t;++r){e=n[r];i[e[0]]=e[1]}return i};o=function(n){var r,t,e=[];for(r in n){t=n[r];e.push([r,t])}return e};a=m(function(n,r){var t,e,i,u,o={};for(t=0,e=n.length;t<e;++t){i=t;u=n[t];o[u]=r[i]}return o});f=function(n){var r,t,e,i;r=[];t=[];for(e in n){i=n[e];r.push(e);t.push(i)}return[r,t]};c=function(n){var r;for(r in n){return false}return true};l=m(function(n,r){var t,e;for(t in r){e=r[t];n(e)}return r});s=m(function(n,r){var t,e,i={};for(t in r){e=r[t];i[t]=n(e)}return i});h=function(n){var r,t,e={};for(r in n){t=n[r];if(t){e[r]=t}}return e};p=m(function(n,r){var t,e,i={};for(t in r){e=r[t];if(n(e)){i[t]=e}}return i});v=m(function(n,r){var t,e,i={};for(t in r){e=r[t];if(!n(e)){i[t]=e}}return i});g=m(function(n,r){var t,e,i,u;t={};e={};for(i in r){u=r[i];(n(u)?t:e)[i]=u}return[t,e]});d=m(function(n,r){var t,e;for(t in r){e=r[t];if(n(e)){return e}}});r.exports={values:e,keys:i,pairsToObj:u,objToPairs:o,listsToObj:a,objToLists:f,empty:c,each:l,map:s,filter:p,compact:h,reject:v,partition:g,find:d};function m(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)<t.length&&arguments.length?u.call(i,n):t.apply(i,n)}:t};return u()}},{}],5:[function(n,r,t){
// Generated by LiveScript 1.6.0
var e,i,u,o,a,f,c,l,s,h,p,v,g;e=d(function(n,r){return r.split(n)});i=d(function(n,r){return r.join(n)});u=function(n){if(!n.length){return[]}return n.split("\n")};o=function(n){return n.join("\n")};a=function(n){if(!n.length){return[]}return n.split(/[ ]+/)};f=function(n){return n.join(" ")};c=function(n){return n.split("")};l=function(n){return n.join("")};s=function(n){return n.split("").reverse().join("")};h=d(function(n,r){var t,e;t="";for(e=0;e<n;++e){t+=r}return t});p=function(n){return n.charAt(0).toUpperCase()+n.slice(1)};v=function(n){return n.replace(/[-_]+(.)?/g,function(n,r){return(r!=null?r:"").toUpperCase()})};g=function(n){return n.replace(/([^-A-Z])([A-Z]+)/g,function(n,r,t){return r+"-"+(t.length>1?t:t.toLowerCase())}).replace(/^([A-Z]+)/,function(n,r){if(r.length>1){return r+"-"}else{return r.toLowerCase()}})};r.exports={split:e,join:i,lines:u,unlines:o,words:a,unwords:f,chars:c,unchars:l,reverse:s,repeat:h,capitalize:p,camelize:v,dasherize:g};function d(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)<t.length&&arguments.length?u.call(i,n):t.apply(i,n)}:t};return u()}},{}],"prelude-ls":[function(n,r,t){
// Generated by LiveScript 1.6.0
var e,i,u,o,a,f,c,l,s,h={}.toString;e=n("./Func.js");i=n("./List.js");u=n("./Obj.js");o=n("./Str.js");a=n("./Num.js");f=function(n){return n};c=p(function(n,r){return h.call(r).slice(8,-1)===n});l=p(function(n,r){var t,e=[];for(t=0;t<n;++t){e.push(r)}return e});o.empty=i.empty;o.slice=i.slice;o.take=i.take;o.drop=i.drop;o.splitAt=i.splitAt;o.takeWhile=i.takeWhile;o.dropWhile=i.dropWhile;o.span=i.span;o.breakStr=i.breakList;s={Func:e,List:i,Obj:u,Str:o,Num:a,id:f,isType:c,replicate:l};s.each=i.each;s.map=i.map;s.filter=i.filter;s.compact=i.compact;s.reject=i.reject;s.partition=i.partition;s.find=i.find;s.head=i.head;s.first=i.first;s.tail=i.tail;s.last=i.last;s.initial=i.initial;s.empty=i.empty;s.reverse=i.reverse;s.difference=i.difference;s.intersection=i.intersection;s.union=i.union;s.countBy=i.countBy;s.groupBy=i.groupBy;s.fold=i.fold;s.foldl=i.foldl;s.fold1=i.fold1;s.foldl1=i.foldl1;s.foldr=i.foldr;s.foldr1=i.foldr1;s.unfoldr=i.unfoldr;s.andList=i.andList;s.orList=i.orList;s.any=i.any;s.all=i.all;s.unique=i.unique;s.uniqueBy=i.uniqueBy;s.sort=i.sort;s.sortWith=i.sortWith;s.sortBy=i.sortBy;s.sum=i.sum;s.product=i.product;s.mean=i.mean;s.average=i.average;s.concat=i.concat;s.concatMap=i.concatMap;s.flatten=i.flatten;s.maximum=i.maximum;s.minimum=i.minimum;s.maximumBy=i.maximumBy;s.minimumBy=i.minimumBy;s.scan=i.scan;s.scanl=i.scanl;s.scan1=i.scan1;s.scanl1=i.scanl1;s.scanr=i.scanr;s.scanr1=i.scanr1;s.slice=i.slice;s.take=i.take;s.drop=i.drop;s.splitAt=i.splitAt;s.takeWhile=i.takeWhile;s.dropWhile=i.dropWhile;s.span=i.span;s.breakList=i.breakList;s.zip=i.zip;s.zipWith=i.zipWith;s.zipAll=i.zipAll;s.zipAllWith=i.zipAllWith;s.at=i.at;s.elemIndex=i.elemIndex;s.elemIndices=i.elemIndices;s.findIndex=i.findIndex;s.findIndices=i.findIndices;s.apply=e.apply;s.curry=e.curry;s.flip=e.flip;s.fix=e.fix;s.over=e.over;s.split=o.split;s.join=o.join;s.lines=o.lines;s.unlines=o.unlines;s.words=o.words;s.unwords=o.unwords;s.chars=o.chars;s.unchars=o.unchars;s.repeat=o.repeat;s.capitalize=o.capitalize;s.camelize=o.camelize;s.dasherize=o.dasherize;s.values=u.values;s.keys=u.keys;s.pairsToObj=u.pairsToObj;s.objToPairs=u.objToPairs;s.listsToObj=u.listsToObj;s.objToLists=u.objToLists;s.max=a.max;s.min=a.min;s.negate=a.negate;s.abs=a.abs;s.signum=a.signum;s.quot=a.quot;s.rem=a.rem;s.div=a.div;s.mod=a.mod;s.recip=a.recip;s.pi=a.pi;s.tau=a.tau;s.exp=a.exp;s.sqrt=a.sqrt;s.ln=a.ln;s.pow=a.pow;s.sin=a.sin;s.tan=a.tan;s.cos=a.cos;s.acos=a.acos;s.asin=a.asin;s.atan=a.atan;s.atan2=a.atan2;s.truncate=a.truncate;s.round=a.round;s.ceiling=a.ceiling;s.floor=a.floor;s.isItNaN=a.isItNaN;s.even=a.even;s.odd=a.odd;s.gcd=a.gcd;s.lcm=a.lcm;s.VERSION="1.2.1";r.exports=s;function p(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)<t.length&&arguments.length?u.call(i,n):t.apply(i,n)}:t};return u()}},{"./Func.js":1,"./List.js":2,"./Num.js":3,"./Obj.js":4,"./Str.js":5}]},{},[]);
================================================
FILE: browser/prelude-browser.js
================================================
// Generated by LiveScript 1.6.0
// prelude.ls 1.2.1
// Copyright (c) George Zahariev
// Released under the MIT License
// https://raw.githubusercontent.com/gkz/prelude-ls/master/LICENSE
require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
// Generated by LiveScript 1.6.0
var apply, curry, flip, fix, over, memoize, toString$ = {}.toString;
apply = curry$(function(f, list){
return f.apply(null, list);
});
curry = function(f){
return curry$(f);
};
flip = curry$(function(f, x, y){
return f(y, x);
});
fix = function(f){
return function(g){
return function(){
return f(g(g)).apply(null, arguments);
};
}(function(g){
return function(){
return f(g(g)).apply(null, arguments);
};
});
};
over = curry$(function(f, g, x, y){
return f(g(x), g(y));
});
memoize = function(f){
var memo;
memo = {};
return function(){
var args, res$, i$, to$, key, arg;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
key = (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
arg = ref$[i$];
results$.push(arg + toString$.call(arg).slice(8, -1));
}
return results$;
}()).join('');
return memo[key] = key in memo
? memo[key]
: f.apply(null, args);
};
};
module.exports = {
curry: curry,
flip: flip,
fix: fix,
apply: apply,
over: over,
memoize: memoize
};
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();
}
},{}],2:[function(require,module,exports){
// 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; }
},{}],3:[function(require,module,exports){
// Generated by LiveScript 1.6.0
var max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm;
max = curry$(function(x$, y$){
return x$ > y$ ? x$ : y$;
});
min = curry$(function(x$, y$){
return x$ < y$ ? x$ : y$;
});
negate = function(x){
return -x;
};
abs = Math.abs;
signum = function(x){
if (x < 0) {
return -1;
} else if (x > 0) {
return 1;
} else {
return 0;
}
};
quot = curry$(function(x, y){
return ~~(x / y);
});
rem = curry$(function(x$, y$){
return x$ % y$;
});
div = curry$(function(x, y){
return Math.floor(x / y);
});
mod = curry$(function(x$, y$){
var ref$;
return ((x$) % (ref$ = y$) + ref$) % ref$;
});
recip = (function(it){
return 1 / it;
});
pi = Math.PI;
tau = pi * 2;
exp = Math.exp;
sqrt = Math.sqrt;
ln = Math.log;
pow = curry$(function(x$, y$){
return Math.pow(x$, y$);
});
sin = Math.sin;
tan = Math.tan;
cos = Math.cos;
asin = Math.asin;
acos = Math.acos;
atan = Math.atan;
atan2 = curry$(function(x, y){
return Math.atan2(x, y);
});
truncate = function(x){
return ~~x;
};
round = Math.round;
ceiling = Math.ceil;
floor = Math.floor;
isItNaN = function(x){
return x !== x;
};
even = function(x){
return x % 2 === 0;
};
odd = function(x){
return x % 2 !== 0;
};
gcd = curry$(function(x, y){
var z;
x = Math.abs(x);
y = Math.abs(y);
while (y !== 0) {
z = x % y;
x = y;
y = z;
}
return x;
});
lcm = curry$(function(x, y){
return Math.abs(Math.floor(x / gcd(x, y) * y));
});
module.exports = {
max: max,
min: min,
negate: negate,
abs: abs,
signum: signum,
quot: quot,
rem: rem,
div: div,
mod: mod,
recip: recip,
pi: pi,
tau: tau,
exp: exp,
sqrt: sqrt,
ln: ln,
pow: pow,
sin: sin,
tan: tan,
cos: cos,
acos: acos,
asin: asin,
atan: atan,
atan2: atan2,
truncate: truncate,
round: round,
ceiling: ceiling,
floor: floor,
isItNaN: isItNaN,
even: even,
odd: odd,
gcd: gcd,
lcm: lcm
};
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();
}
},{}],4:[function(require,module,exports){
// Generated by LiveScript 1.6.0
var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find;
values = function(object){
var i$, x, results$ = [];
for (i$ in object) {
x = object[i$];
results$.push(x);
}
return results$;
};
keys = function(object){
var x, results$ = [];
for (x in object) {
results$.push(x);
}
return results$;
};
pairsToObj = function(object){
var i$, len$, x, resultObj$ = {};
for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
x = object[i$];
resultObj$[x[0]] = x[1];
}
return resultObj$;
};
objToPairs = function(object){
var key, value, results$ = [];
for (key in object) {
value = object[key];
results$.push([key, value]);
}
return results$;
};
listsToObj = curry$(function(keys, values){
var i$, len$, i, key, resultObj$ = {};
for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) {
i = i$;
key = keys[i$];
resultObj$[key] = values[i];
}
return resultObj$;
});
objToLists = function(object){
var keys, values, key, value;
keys = [];
values = [];
for (key in object) {
value = object[key];
keys.push(key);
values.push(value);
}
return [keys, values];
};
empty = function(object){
var x;
for (x in object) {
return false;
}
return true;
};
each = curry$(function(f, object){
var i$, x;
for (i$ in object) {
x = object[i$];
f(x);
}
return object;
});
map = curry$(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
resultObj$[k] = f(x);
}
return resultObj$;
});
compact = function(object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (x) {
resultObj$[k] = x;
}
}
return resultObj$;
};
filter = curry$(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (f(x)) {
resultObj$[k] = x;
}
}
return resultObj$;
});
reject = curry$(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (!f(x)) {
resultObj$[k] = x;
}
}
return resultObj$;
});
partition = curry$(function(f, object){
var passed, failed, k, x;
passed = {};
failed = {};
for (k in object) {
x = object[k];
(f(x) ? passed : failed)[k] = x;
}
return [passed, failed];
});
find = curry$(function(f, object){
var i$, x;
for (i$ in object) {
x = object[i$];
if (f(x)) {
return x;
}
}
});
module.exports = {
values: values,
keys: keys,
pairsToObj: pairsToObj,
objToPairs: objToPairs,
listsToObj: listsToObj,
objToLists: objToLists,
empty: empty,
each: each,
map: map,
filter: filter,
compact: compact,
reject: reject,
partition: partition,
find: find
};
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();
}
},{}],5:[function(require,module,exports){
// Generated by LiveScript 1.6.0
var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize;
split = curry$(function(sep, str){
return str.split(sep);
});
join = curry$(function(sep, xs){
return xs.join(sep);
});
lines = function(str){
if (!str.length) {
return [];
}
return str.split('\n');
};
unlines = function(it){
return it.join('\n');
};
words = function(str){
if (!str.length) {
return [];
}
return str.split(/[ ]+/);
};
unwords = function(it){
return it.join(' ');
};
chars = function(it){
return it.split('');
};
unchars = function(it){
return it.join('');
};
reverse = function(str){
return str.split('').reverse().join('');
};
repeat = curry$(function(n, str){
var result, i$;
result = '';
for (i$ = 0; i$ < n; ++i$) {
result += str;
}
return result;
});
capitalize = function(str){
return str.charAt(0).toUpperCase() + str.slice(1);
};
camelize = function(it){
return it.replace(/[-_]+(.)?/g, function(arg$, c){
return (c != null ? c : '').toUpperCase();
});
};
dasherize = function(str){
return str.replace(/([^-A-Z])([A-Z]+)/g, function(arg$, lower, upper){
return lower + "-" + (upper.length > 1
? upper
: upper.toLowerCase());
}).replace(/^([A-Z]+)/, function(arg$, upper){
if (upper.length > 1) {
return upper + "-";
} else {
return upper.toLowerCase();
}
});
};
module.exports = {
split: split,
join: join,
lines: lines,
unlines: unlines,
words: words,
unwords: unwords,
chars: chars,
unchars: unchars,
reverse: reverse,
repeat: repeat,
capitalize: capitalize,
camelize: camelize,
dasherize: dasherize
};
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();
}
},{}],"prelude-ls":[function(require,module,exports){
// Generated by LiveScript 1.6.0
var Func, List, Obj, Str, Num, id, isType, replicate, prelude, toString$ = {}.toString;
Func = require('./Func.js');
List = require('./List.js');
Obj = require('./Obj.js');
Str = require('./Str.js');
Num = require('./Num.js');
id = function(x){
return x;
};
isType = curry$(function(type, x){
return toString$.call(x).slice(8, -1) === type;
});
replicate = curry$(function(n, x){
var i$, results$ = [];
for (i$ = 0; i$ < n; ++i$) {
results$.push(x);
}
return results$;
});
Str.empty = List.empty;
Str.slice = List.slice;
Str.take = List.take;
Str.drop = List.drop;
Str.splitAt = List.splitAt;
Str.takeWhile = List.takeWhile;
Str.dropWhile = List.dropWhile;
Str.span = List.span;
Str.breakStr = List.breakList;
prelude = {
Func: Func,
List: List,
Obj: Obj,
Str: Str,
Num: Num,
id: id,
isType: isType,
replicate: replicate
};
prelude.each = List.each;
prelude.map = List.map;
prelude.filter = List.filter;
prelude.compact = List.compact;
prelude.reject = List.reject;
prelude.partition = List.partition;
prelude.find = List.find;
prelude.head = List.head;
prelude.first = List.first;
prelude.tail = List.tail;
prelude.last = List.last;
prelude.initial = List.initial;
prelude.empty = List.empty;
prelude.reverse = List.reverse;
prelude.difference = List.difference;
prelude.intersection = List.intersection;
prelude.union = List.union;
prelude.countBy = List.countBy;
prelude.groupBy = List.groupBy;
prelude.fold = List.fold;
prelude.foldl = List.foldl;
prelude.fold1 = List.fold1;
prelude.foldl1 = List.foldl1;
prelude.foldr = List.foldr;
prelude.foldr1 = List.foldr1;
prelude.unfoldr = List.unfoldr;
prelude.andList = List.andList;
prelude.orList = List.orList;
prelude.any = List.any;
prelude.all = List.all;
prelude.unique = List.unique;
prelude.uniqueBy = List.uniqueBy;
prelude.sort = List.sort;
prelude.sortWith = List.sortWith;
prelude.sortBy = List.sortBy;
prelude.sum = List.sum;
prelude.product = List.product;
prelude.mean = List.mean;
prelude.average = List.average;
prelude.concat = List.concat;
prelude.concatMap = List.concatMap;
prelude.flatten = List.flatten;
prelude.maximum = List.maximum;
prelude.minimum = List.minimum;
prelude.maximumBy = List.maximumBy;
prelude.minimumBy = List.minimumBy;
prelude.scan = List.scan;
prelude.scanl = List.scanl;
prelude.scan1 = List.scan1;
prelude.scanl1 = List.scanl1;
prelude.scanr = List.scanr;
prelude.scanr1 = List.scanr1;
prelude.slice = List.slice;
prelude.take = List.take;
prelude.drop = List.drop;
prelude.splitAt = List.splitAt;
prelude.takeWhile = List.takeWhile;
prelude.dropWhile = List.dropWhile;
prelude.span = List.span;
prelude.breakList = List.breakList;
prelude.zip = List.zip;
prelude.zipWith = List.zipWith;
prelude.zipAll = List.zipAll;
prelude.zipAllWith = List.zipAllWith;
prelude.at = List.at;
prelude.elemIndex = List.elemIndex;
prelude.elemIndices = List.elemIndices;
prelude.findIndex = List.findIndex;
prelude.findIndices = List.findIndices;
prelude.apply = Func.apply;
prelude.curry = Func.curry;
prelude.flip = Func.flip;
prelude.fix = Func.fix;
prelude.over = Func.over;
prelude.split = Str.split;
prelude.join = Str.join;
prelude.lines = Str.lines;
prelude.unlines = Str.unlines;
prelude.words = Str.words;
prelude.unwords = Str.unwords;
prelude.chars = Str.chars;
prelude.unchars = Str.unchars;
prelude.repeat = Str.repeat;
prelude.capitalize = Str.capitalize;
prelude.camelize = Str.camelize;
prelude.dasherize = Str.dasherize;
prelude.values = Obj.values;
prelude.keys = Obj.keys;
prelude.pairsToObj = Obj.pairsToObj;
prelude.objToPairs = Obj.objToPairs;
prelude.listsToObj = Obj.listsToObj;
prelude.objToLists = Obj.objToLists;
prelude.max = Num.max;
prelude.min = Num.min;
prelude.negate = Num.negate;
prelude.abs = Num.abs;
prelude.signum = Num.signum;
prelude.quot = Num.quot;
prelude.rem = Num.rem;
prelude.div = Num.div;
prelude.mod = Num.mod;
prelude.recip = Num.recip;
prelude.pi = Num.pi;
prelude.tau = Num.tau;
prelude.exp = Num.exp;
prelude.sqrt = Num.sqrt;
prelude.ln = Num.ln;
prelude.pow = Num.pow;
prelude.sin = Num.sin;
prelude.tan = Num.tan;
prelude.cos = Num.cos;
prelude.acos = Num.acos;
prelude.asin = Num.asin;
prelude.atan = Num.atan;
prelude.atan2 = Num.atan2;
prelude.truncate = Num.truncate;
prelude.round = Num.round;
prelude.ceiling = Num.ceiling;
prelude.floor = Num.floor;
prelude.isItNaN = Num.isItNaN;
prelude.even = Num.even;
prelude.odd = Num.odd;
prelude.gcd = Num.gcd;
prelude.lcm = Num.lcm;
prelude.VERSION = '1.2.1';
module.exports = prelude;
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();
}
},{"./Func.js":1,"./List.js":2,"./Num.js":3,"./Obj.js":4,"./Str.js":5}]},{},[]);
================================================
FILE: lib/Func.js
================================================
// Generated by LiveScript 1.6.0
var apply, curry, flip, fix, over, memoize, toString$ = {}.toString;
apply = curry$(function(f, list){
return f.apply(null, list);
});
curry = function(f){
return curry$(f);
};
flip = curry$(function(f, x, y){
return f(y, x);
});
fix = function(f){
return function(g){
return function(){
return f(g(g)).apply(null, arguments);
};
}(function(g){
return function(){
return f(g(g)).apply(null, arguments);
};
});
};
over = curry$(function(f, g, x, y){
return f(g(x), g(y));
});
memoize = function(f){
var memo;
memo = {};
return function(){
var args, res$, i$, to$, key, arg;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
key = (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
arg = ref$[i$];
results$.push(arg + toString$.call(arg).slice(8, -1));
}
return results$;
}()).join('');
return memo[key] = key in memo
? memo[key]
: f.apply(null, args);
};
};
module.exports = {
curry: curry,
flip: flip,
fix: fix,
apply: apply,
over: over,
memoize: memoize
};
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();
}
================================================
FILE: lib/List.js
================================================
// 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; }
================================================
FILE: lib/Num.js
================================================
// Generated by LiveScript 1.6.0
var max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm;
max = curry$(function(x$, y$){
return x$ > y$ ? x$ : y$;
});
min = curry$(function(x$, y$){
return x$ < y$ ? x$ : y$;
});
negate = function(x){
return -x;
};
abs = Math.abs;
signum = function(x){
if (x < 0) {
return -1;
} else if (x > 0) {
return 1;
} else {
return 0;
}
};
quot = curry$(function(x, y){
return ~~(x / y);
});
rem = curry$(function(x$, y$){
return x$ % y$;
});
div = curry$(function(x, y){
return Math.floor(x / y);
});
mod = curry$(function(x$, y$){
var ref$;
return ((x$) % (ref$ = y$) + ref$) % ref$;
});
recip = (function(it){
return 1 / it;
});
pi = Math.PI;
tau = pi * 2;
exp = Math.exp;
sqrt = Math.sqrt;
ln = Math.log;
pow = curry$(function(x$, y$){
return Math.pow(x$, y$);
});
sin = Math.sin;
tan = Math.tan;
cos = Math.cos;
asin = Math.asin;
acos = Math.acos;
atan = Math.atan;
atan2 = curry$(function(x, y){
return Math.atan2(x, y);
});
truncate = function(x){
return ~~x;
};
round = Math.round;
ceiling = Math.ceil;
floor = Math.floor;
isItNaN = function(x){
return x !== x;
};
even = function(x){
return x % 2 === 0;
};
odd = function(x){
return x % 2 !== 0;
};
gcd = curry$(function(x, y){
var z;
x = Math.abs(x);
y = Math.abs(y);
while (y !== 0) {
z = x % y;
x = y;
y = z;
}
return x;
});
lcm = curry$(function(x, y){
return Math.abs(Math.floor(x / gcd(x, y) * y));
});
module.exports = {
max: max,
min: min,
negate: negate,
abs: abs,
signum: signum,
quot: quot,
rem: rem,
div: div,
mod: mod,
recip: recip,
pi: pi,
tau: tau,
exp: exp,
sqrt: sqrt,
ln: ln,
pow: pow,
sin: sin,
tan: tan,
cos: cos,
acos: acos,
asin: asin,
atan: atan,
atan2: atan2,
truncate: truncate,
round: round,
ceiling: ceiling,
floor: floor,
isItNaN: isItNaN,
even: even,
odd: odd,
gcd: gcd,
lcm: lcm
};
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();
}
================================================
FILE: lib/Obj.js
================================================
// Generated by LiveScript 1.6.0
var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find;
values = function(object){
var i$, x, results$ = [];
for (i$ in object) {
x = object[i$];
results$.push(x);
}
return results$;
};
keys = function(object){
var x, results$ = [];
for (x in object) {
results$.push(x);
}
return results$;
};
pairsToObj = function(object){
var i$, len$, x, resultObj$ = {};
for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
x = object[i$];
resultObj$[x[0]] = x[1];
}
return resultObj$;
};
objToPairs = function(object){
var key, value, results$ = [];
for (key in object) {
value = object[key];
results$.push([key, value]);
}
return results$;
};
listsToObj = curry$(function(keys, values){
var i$, len$, i, key, resultObj$ = {};
for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) {
i = i$;
key = keys[i$];
resultObj$[key] = values[i];
}
return resultObj$;
});
objToLists = function(object){
var keys, values, key, value;
keys = [];
values = [];
for (key in object) {
value = object[key];
keys.push(key);
values.push(value);
}
return [keys, values];
};
empty = function(object){
var x;
for (x in object) {
return false;
}
return true;
};
each = curry$(function(f, object){
var i$, x;
for (i$ in object) {
x = object[i$];
f(x);
}
return object;
});
map = curry$(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
resultObj$[k] = f(x);
}
return resultObj$;
});
compact = function(object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (x) {
resultObj$[k] = x;
}
}
return resultObj$;
};
filter = curry$(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (f(x)) {
resultObj$[k] = x;
}
}
return resultObj$;
});
reject = curry$(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (!f(x)) {
resultObj$[k] = x;
}
}
return resultObj$;
});
partition = curry$(function(f, object){
var passed, failed, k, x;
passed = {};
failed = {};
for (k in object) {
x = object[k];
(f(x) ? passed : failed)[k] = x;
}
return [passed, failed];
});
find = curry$(function(f, object){
var i$, x;
for (i$ in object) {
x = object[i$];
if (f(x)) {
return x;
}
}
});
module.exports = {
values: values,
keys: keys,
pairsToObj: pairsToObj,
objToPairs: objToPairs,
listsToObj: listsToObj,
objToLists: objToLists,
empty: empty,
each: each,
map: map,
filter: filter,
compact: compact,
reject: reject,
partition: partition,
find: find
};
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();
}
================================================
FILE: lib/Str.js
================================================
// Generated by LiveScript 1.6.0
var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize;
split = curry$(function(sep, str){
return str.split(sep);
});
join = curry$(function(sep, xs){
return xs.join(sep);
});
lines = function(str){
if (!str.length) {
return [];
}
return str.split('\n');
};
unlines = function(it){
return it.join('\n');
};
words = function(str){
if (!str.length) {
return [];
}
return str.split(/[ ]+/);
};
unwords = function(it){
return it.join(' ');
};
chars = function(it){
return it.split('');
};
unchars = function(it){
return it.join('');
};
reverse = function(str){
return str.split('').reverse().join('');
};
repeat = curry$(function(n, str){
var result, i$;
result = '';
for (i$ = 0; i$ < n; ++i$) {
result += str;
}
return result;
});
capitalize = function(str){
return str.charAt(0).toUpperCase() + str.slice(1);
};
camelize = function(it){
return it.replace(/[-_]+(.)?/g, function(arg$, c){
return (c != null ? c : '').toUpperCase();
});
};
dasherize = function(str){
return str.replace(/([^-A-Z])([A-Z]+)/g, function(arg$, lower, upper){
return lower + "-" + (upper.length > 1
? upper
: upper.toLowerCase());
}).replace(/^([A-Z]+)/, function(arg$, upper){
if (upper.length > 1) {
return upper + "-";
} else {
return upper.toLowerCase();
}
});
};
module.exports = {
split: split,
join: join,
lines: lines,
unlines: unlines,
words: words,
unwords: unwords,
chars: chars,
unchars: unchars,
reverse: reverse,
repeat: repeat,
capitalize: capitalize,
camelize: camelize,
dasherize: dasherize
};
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();
}
================================================
FILE: lib/index.js
================================================
// Generated by LiveScript 1.6.0
var Func, List, Obj, Str, Num, id, isType, replicate, prelude, toString$ = {}.toString;
Func = require('./Func.js');
List = require('./List.js');
Obj = require('./Obj.js');
Str = require('./Str.js');
Num = require('./Num.js');
id = function(x){
return x;
};
isType = curry$(function(type, x){
return toString$.call(x).slice(8, -1) === type;
});
replicate = curry$(function(n, x){
var i$, results$ = [];
for (i$ = 0; i$ < n; ++i$) {
results$.push(x);
}
return results$;
});
Str.empty = List.empty;
Str.slice = List.slice;
Str.take = List.take;
Str.drop = List.drop;
Str.splitAt = List.splitAt;
Str.takeWhile = List.takeWhile;
Str.dropWhile = List.dropWhile;
Str.span = List.span;
Str.breakStr = List.breakList;
prelude = {
Func: Func,
List: List,
Obj: Obj,
Str: Str,
Num: Num,
id: id,
isType: isType,
replicate: replicate
};
prelude.each = List.each;
prelude.map = List.map;
prelude.filter = List.filter;
prelude.compact = List.compact;
prelude.reject = List.reject;
prelude.partition = List.partition;
prelude.find = List.find;
prelude.head = List.head;
prelude.first = List.first;
prelude.tail = List.tail;
prelude.last = List.last;
prelude.initial = List.initial;
prelude.empty = List.empty;
prelude.reverse = List.reverse;
prelude.difference = List.difference;
prelude.intersection = List.intersection;
prelude.union = List.union;
prelude.countBy = List.countBy;
prelude.groupBy = List.groupBy;
prelude.fold = List.fold;
prelude.foldl = List.foldl;
prelude.fold1 = List.fold1;
prelude.foldl1 = List.foldl1;
prelude.foldr = List.foldr;
prelude.foldr1 = List.foldr1;
prelude.unfoldr = List.unfoldr;
prelude.andList = List.andList;
prelude.orList = List.orList;
prelude.any = List.any;
prelude.all = List.all;
prelude.unique = List.unique;
prelude.uniqueBy = List.uniqueBy;
prelude.sort = List.sort;
prelude.sortWith = List.sortWith;
prelude.sortBy = List.sortBy;
prelude.sum = List.sum;
prelude.product = List.product;
prelude.mean = List.mean;
prelude.average = List.average;
prelude.concat = List.concat;
prelude.concatMap = List.concatMap;
prelude.flatten = List.flatten;
prelude.maximum = List.maximum;
prelude.minimum = List.minimum;
prelude.maximumBy = List.maximumBy;
prelude.minimumBy = List.minimumBy;
prelude.scan = List.scan;
prelude.scanl = List.scanl;
prelude.scan1 = List.scan1;
prelude.scanl1 = List.scanl1;
prelude.scanr = List.scanr;
prelude.scanr1 = List.scanr1;
prelude.slice = List.slice;
prelude.take = List.take;
prelude.drop = List.drop;
prelude.splitAt = List.splitAt;
prelude.takeWhile = List.takeWhile;
prelude.dropWhile = List.dropWhile;
prelude.span = List.span;
prelude.breakList = List.breakList;
prelude.zip = List.zip;
prelude.zipWith = List.zipWith;
prelude.zipAll = List.zipAll;
prelude.zipAllWith = List.zipAllWith;
prelude.at = List.at;
prelude.elemIndex = List.elemIndex;
prelude.elemIndices = List.elemIndices;
prelude.findIndex = List.findIndex;
prelude.findIndices = List.findIndices;
prelude.apply = Func.apply;
prelude.curry = Func.curry;
prelude.flip = Func.flip;
prelude.fix = Func.fix;
prelude.over = Func.over;
prelude.split = Str.split;
prelude.join = Str.join;
prelude.lines = Str.lines;
prelude.unlines = Str.unlines;
prelude.words = Str.words;
prelude.unwords = Str.unwords;
prelude.chars = Str.chars;
prelude.unchars = Str.unchars;
prelude.repeat = Str.repeat;
prelude.capitalize = Str.capitalize;
prelude.camelize = Str.camelize;
prelude.dasherize = Str.dasherize;
prelude.values = Obj.values;
prelude.keys = Obj.keys;
prelude.pairsToObj = Obj.pairsToObj;
prelude.objToPairs = Obj.objToPairs;
prelude.listsToObj = Obj.listsToObj;
prelude.objToLists = Obj.objToLists;
prelude.max = Num.max;
prelude.min = Num.min;
prelude.negate = Num.negate;
prelude.abs = Num.abs;
prelude.signum = Num.signum;
prelude.quot = Num.quot;
prelude.rem = Num.rem;
prelude.div = Num.div;
prelude.mod = Num.mod;
prelude.recip = Num.recip;
prelude.pi = Num.pi;
prelude.tau = Num.tau;
prelude.exp = Num.exp;
prelude.sqrt = Num.sqrt;
prelude.ln = Num.ln;
prelude.pow = Num.pow;
prelude.sin = Num.sin;
prelude.tan = Num.tan;
prelude.cos = Num.cos;
prelude.acos = Num.acos;
prelude.asin = Num.asin;
prelude.atan = Num.atan;
prelude.atan2 = Num.atan2;
prelude.truncate = Num.truncate;
prelude.round = Num.round;
prelude.ceiling = Num.ceiling;
prelude.floor = Num.floor;
prelude.isItNaN = Num.isItNaN;
prelude.even = Num.even;
prelude.odd = Num.odd;
prelude.gcd = Num.gcd;
prelude.lcm = Num.lcm;
prelude.VERSION = '1.2.1';
module.exports = prelude;
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();
}
================================================
FILE: package.json
================================================
{
"name": "prelude-ls",
"version": "1.2.1",
"author": "George Zahariev <z@georgezahariev.com>",
"description": "prelude.ls is a functionally oriented utility library. It is powerful and flexible. Almost all of its functions are curried. It is written in, and is the recommended base library for, LiveScript.",
"keywords": [
"prelude",
"livescript",
"utility",
"ls",
"coffeescript",
"javascript",
"library",
"functional",
"array",
"list",
"object",
"string"
],
"main": "lib/",
"files": [
"lib/",
"README.md",
"LICENSE"
],
"homepage": "http://preludels.com",
"bugs": "https://github.com/gkz/prelude-ls/issues",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
},
"repository": {
"type": "git",
"url": "git://github.com/gkz/prelude-ls.git"
},
"scripts": {
"test": "make test"
},
"devDependencies": {
"livescript": "^1.6.0",
"uglify-js": "^3.8.1",
"mocha": "^10.2.0",
"browserify": "^16.5.1",
"sinon": "~8.0.1"
}
}
================================================
FILE: package.json.ls
================================================
name: 'prelude-ls'
version: '1.2.1'
author: 'George Zahariev <z@georgezahariev.com>'
description: "prelude.ls is a functionally oriented utility library. It is powerful and flexible. Almost all of its functions are curried. It is written in, and is the recommended base library for, LiveScript."
keywords:
'prelude'
'livescript'
'utility'
'ls'
'coffeescript'
'javascript'
'library'
'functional'
'array'
'list'
'object'
'string'
main: 'lib/'
files:
'lib/'
'README.md'
'LICENSE'
homepage: 'http://preludels.com'
bugs: 'https://github.com/gkz/prelude-ls/issues'
license: 'MIT'
engines:
node: '>= 0.8.0'
repository:
type: 'git'
url: 'git://github.com/gkz/prelude-ls.git'
scripts:
test: "make test"
dev-dependencies:
livescript: "^1.6.0",
'uglify-js': "^3.8.1",
mocha: "^7.1.1",
browserify: "^16.5.1",
sinon: "~8.0.1"
================================================
FILE: preroll.ls
================================================
version = require './lib' .VERSION
{VERSION: ls-version} = require 'livescript'
console.log """
// Generated by LiveScript #ls-version
// prelude.ls #version
// Copyright (c) George Zahariev
// Released under the MIT License
// https://raw.githubusercontent.com/gkz/prelude-ls/master/LICENSE
"""
================================================
FILE: src/Func.ls
================================================
apply = (f, list) -->
f.apply null, list
curry = (f) ->
curry$ f # using util method curry$ from livescript
flip = (f, x, y) --> f y, x
fix = (f) ->
( (g) -> -> f(g g) ...arguments ) do
(g) -> -> f(g g) ...arguments
over = (f, g, x, y) --> f (g x), (g y)
memoize = (f) ->
memo = {}
(...args) ->
key = [arg + typeof! arg for arg in args].join ''
memo[key] = if key of memo then memo[key] else f ...args
#? wrap
module.exports = {
curry, flip, fix, apply, over, memoize
}
================================================
FILE: src/List.ls
================================================
each = (f, xs) -->
for x in xs
f x
xs
map = (f, xs) -->
[f x for x in xs]
compact = (xs) -->
[x for x in xs when x]
filter = (f, xs) -->
[x for x in xs when f x]
reject = (f, xs) -->
[x for x in xs when not f x]
remove = (el, xs) -->
i = elem-index el, xs
xs.slice!
..splice i, 1 if i?
partition = (f, xs) -->
passed = []
failed = []
for x in xs
(if f x then passed else failed).push x
[passed, failed]
find = (f, xs) -->
for x in xs when f x
return x
void
head = first = (xs) ->
xs.0
tail = (xs) ->
return void unless xs.length
xs.slice 1
last = (xs) ->
xs[*-1]
initial = (xs) ->
return void unless xs.length
xs.slice 0, -1
empty = (xs) ->
not xs.length
reverse = (xs) ->
xs.concat!.reverse!
unique = (xs) ->
result = []
for x in xs when x not in result
result.push x
result
unique-by = (f, xs) -->
seen = []
for x in xs
val = f x
continue if val in seen
seen.push val
x
fold = foldl = (f, memo, xs) -->
for x in xs
memo = f memo, x
memo
fold1 = foldl1 = (f, xs) -->
fold f, xs.0, xs.slice 1
foldr = (f, memo, xs) -->
for x in xs by -1
memo = f x, memo
memo
foldr1 = (f, xs) -->
foldr f, xs[*-1], xs.slice 0, -1
unfoldr = (f, b) -->
result = []
x = b
while (f x)?
result.push that.0
x = that.1
result
concat = (xss) ->
[].concat.apply [], xss
concat-map = (f, xs) -->
[].concat.apply [], [f x for x in xs]
flatten = (xs) -->
[].concat.apply [], [(if typeof! x is 'Array' then flatten x else x) for x in xs]
difference = (xs, ...yss) ->
results = []
:outer for x in xs
for ys in yss
continue outer if x in ys
results.push x
results
intersection = (xs, ...yss) ->
results = []
:outer for x in xs
for ys in yss
continue outer unless x in ys
results.push x
results
union = (...xss) ->
results = []
for xs in xss
for x in xs
results.push x unless x in results
results
count-by = (f, xs) -->
results = {}
for x in xs
key = f x
if key of results
results[key] += 1
else
results[key] = 1
results
group-by = (f, xs) -->
results = {}
for x in xs
key = f x
if key of results
results[key].push x
else
results[key] = [x]
results
and-list = (xs) ->
for x in xs when not x
return false
true
or-list = (xs) ->
for x in xs when x
return true
false
any = (f, xs) -->
for x in xs when f x
return true
false
all = (f, xs) -->
for x in xs when not f x
return false
true
sort = (xs) ->
xs.concat!.sort (x, y) ->
if x > y
1
else if x < y
-1
else
0
sort-with = (f, xs) -->
xs.concat!.sort f
sort-by = (f, xs) -->
xs.concat!.sort (x, y) ->
if (f x) > (f y)
1
else if (f x) < (f y)
-1
else
0
sum = (xs) ->
result = 0
for x in xs
result += x
result
product = (xs) ->
result = 1
for x in xs
result *= x
result
mean = average = (xs) ->
sum = 0
for x in xs
sum += x
sum / xs.length
maximum = (xs) ->
max = xs.0
for x in xs.slice 1 when x > max
max = x
max
minimum = (xs) ->
min = xs.0
for x in xs.slice 1 when x < min
min = x
min
maximum-by = (f, xs) -->
max = xs.0
for x in xs.slice 1 when (f x) > (f max)
max = x
max
minimum-by = (f, xs) -->
min = xs.0
for x in xs.slice 1 when (f x) < (f min)
min = x
min
scan = scanl = (f, memo, xs) -->
last = memo
[memo] ++ [last = f last, x for x in xs]
scan1 = scanl1 = (f, xs) -->
return void unless xs.length
scan f, xs.0, xs.slice 1
scanr = (f, memo, xs) -->
xs = xs.concat!.reverse!
(scan f, memo, xs).reverse!
scanr1 = (f, xs) -->
return void unless xs.length
xs = xs.concat!.reverse!
(scan f, xs.0, xs.slice 1).reverse!
slice = (x, y, xs) -->
xs.slice x, y
take = (n, xs) -->
if n <= 0
xs.slice 0, 0
else
xs.slice 0, n
drop = (n, xs) -->
if n <= 0
xs
else
xs.slice n
split-at = (n, xs) --> [(take n, xs), (drop n, xs)]
take-while = (p, xs) -->
len = xs.length
return xs unless len
i = 0
while i < len and p xs[i]
i += 1
xs.slice 0 i
drop-while = (p, xs) -->
len = xs.length
return xs unless len
i = 0
while i < len and p xs[i]
i += 1
xs.slice i
span = (p, xs) --> [(take-while p, xs), (drop-while p, xs)]
break-list = (p, xs) --> span (not) << p, xs
zip = (xs, ys) -->
result = []
len = ys.length
for x, i in xs
break if i is len
result.push [x, ys[i]]
result
zip-with = (f, xs, ys) -->
result = []
len = ys.length
for x, i in xs
break if i is len
result.push f x, ys[i]
result
zip-all = (...xss) ->
min-length = undefined
for xs in xss
min-length <?= xs.length
[[xs[i] for xs in xss] for i til min-length]
zip-all-with = (f, ...xss) ->
min-length = undefined
for xs in xss
min-length <?= xs.length
[f.apply(null, [xs[i] for xs in xss]) for i til min-length]
at = (n, xs) -->
if n < 0 then xs[xs.length + n] else xs[n]
elem-index = (el, xs) -->
for x, i in xs when x is el
return i
void
elem-indices = (el, xs) -->
[i for x, i in xs when x is el]
find-index = (f, xs) -->
for x, i in xs when f x
return i
void
find-indices = (f, xs) -->
[i for x, i in xs when f x]
module.exports = {
each, map, filter, compact, reject, remove, partition, find,
head, first, tail, last, initial, empty,
reverse, difference, intersection, union, count-by, group-by,
fold, fold1, foldl, foldl1, foldr, foldr1, unfoldr, and-list, or-list,
any, all, unique, unique-by, sort, sort-with, sort-by, sum, product, mean, average,
concat, concat-map, flatten,
maximum, minimum, maximum-by, minimum-by,
scan, scan1, scanl, scanl1, scanr, scanr1,
slice, take, drop, split-at, take-while, drop-while, span, break-list,
zip, zip-with, zip-all, zip-all-with,
at, elem-index, elem-indices, find-index, find-indices,
}
================================================
FILE: src/Num.ls
================================================
max = (>?)
min = (<?)
negate = (x) -> -x
abs = Math.abs
signum = (x) ->
if x < 0
-1
else if x > 0
1
else
0
quot = (x, y) --> ~~(x / y)
rem = (%)
div = (x, y) --> Math.floor x / y
mod = (%%)
recip = (1 /)
pi = Math.PI
tau = pi * 2
exp = Math.exp
sqrt = Math.sqrt
ln = Math.log
pow = (^)
sin = Math.sin
tan = Math.tan
cos = Math.cos
asin = Math.asin
acos = Math.acos
atan = Math.atan
atan2 = (x, y) --> Math.atan2 x, y
truncate = (x) -> ~~x
round = Math.round
ceiling = Math.ceil
floor = Math.floor
is-it-NaN = (x) -> x isnt x
even = (x) -> x % 2 == 0
odd = (x) -> x % 2 != 0
gcd = (x, y) -->
x = Math.abs x
y = Math.abs y
until y is 0
z = x % y
x = y
y = z
x
lcm = (x, y) -->
Math.abs Math.floor (x / (gcd x, y) * y)
module.exports = {
max, min, negate, abs, signum, quot, rem, div, mod, recip,
pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2,
truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm,
}
================================================
FILE: src/Obj.ls
================================================
values = (object) ->
[x for , x of object]
keys = (object) ->
[x for x of object]
pairs-to-obj= (object) ->
{[x.0, x.1] for x in object}
obj-to-pairs = (object) ->
[[key, value] for key, value of object]
lists-to-obj = (keys, values) -->
{[key, values[i]] for key, i in keys}
obj-to-lists = (object) ->
keys = []
values = []
for key, value of object
keys.push key
values.push value
[keys, values]
empty = (object) ->
for x of object then return false
true
each = (f, object) -->
for , x of object then f x
object
map = (f, object) -->
{[k, f x] for k, x of object}
compact = (object) -->
{[k, x] for k, x of object when x}
filter = (f, object) -->
{[k, x] for k, x of object when f x}
reject = (f, object) -->
{[k, x] for k, x of object when not f x}
partition = (f, object) -->
passed = {}
failed = {}
for k, x of object
(if f x then passed else failed)[k] = x
[passed, failed]
find = (f, object) -->
for , x of object when f x then return x
void
module.exports = {
values, keys,
pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists,
empty, each, map, filter, compact, reject, partition, find,
}
================================================
FILE: src/Str.ls
================================================
split = (sep, str) -->
str.split sep
join = (sep, xs) -->
xs.join sep
lines = (str) ->
return [] unless str.length
str.split '\n'
unlines = (.join '\n')
words = (str) ->
return [] unless str.length
str.split /[ ]+/
unwords = (.join ' ')
chars = (.split '')
unchars = (.join '')
reverse = (str) ->
str.split '' .reverse!.join ''
repeat = (n, str) -->
result = ''
for til n
result += str
result
capitalize = (str) ->
(str.char-at 0).to-upper-case! + str.slice 1
camelize = (.replace /[-_]+(.)?/g, (, c) -> (c ? '').to-upper-case!)
# convert camelCase to camel-case, and setJSON to set-JSON
dasherize = (str) ->
str
.replace /([^-A-Z])([A-Z]+)/g, (, lower, upper) ->
"#{lower}-#{if upper.length > 1 then upper else upper.to-lower-case!}"
.replace /^([A-Z]+)/, (, upper) ->
if upper.length > 1 then "#upper-" else upper.to-lower-case!
module.exports = {
split, join, lines, unlines, words, unwords, chars, unchars, reverse,
repeat, capitalize, camelize, dasherize,
}
================================================
FILE: src/index.ls
================================================
require! [
'./Func.js'
'./List.js'
'./Obj.js'
'./Str.js'
'./Num.js'
]
id = (x) -> x
is-type = (type, x) --> typeof! x is type
replicate = (n, x) -->
[x for til n]
Str <<< List{
empty, slice, take, drop, split-at, take-while, drop-while, span, break-str: break-list
}
prelude = {
Func, List, Obj, Str, Num,
id, is-type
replicate,
}
prelude <<< List{
each, map, filter, compact, reject, partition, find,
head, first, tail, last, initial, empty,
reverse, difference, intersection, union, count-by, group-by,
fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, and-list, or-list,
any, all, unique, unique-by, sort, sort-with, sort-by, sum, product, mean, average,
concat, concat-map, flatten,
maximum, minimum, maximum-by, minimum-by,
scan, scanl, scan1, scanl1, scanr, scanr1,
slice, take, drop, split-at, take-while, drop-while, span, break-list,
zip, zip-with, zip-all, zip-all-with,
at, elem-index, elem-indices, find-index, find-indices,
}
prelude <<< Func{
apply, curry, flip, fix, over,
}
prelude <<< Str{
split, join, lines, unlines, words, unwords, chars, unchars,
repeat, capitalize, camelize, dasherize,
}
# not importing all of Obj's functions
prelude <<< Obj{
values, keys,
pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists,
}
prelude <<< Num{
max, min, negate, abs, signum, quot, rem, div, mod, recip,
pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2,
truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm,
}
prelude.VERSION = '1.2.1'
module.exports = prelude
================================================
FILE: test/Func.ls
================================================
require! \sinon
{apply, curry, flip, fix, over, memoize} = require '..' .Func
{strict-equal: eq, not-strict-equal: not-eq, deep-equal: deep-eq, ok} = require 'assert'
suite 'apply' ->
test 'empty list' ->
f = -> 1
eq 1, apply f, []
test 'a couple of args' ->
eq 5, apply (+), [2 3]
test 'curried' ->
f = apply (+)
eq 5, f [2 3]
suite 'curry' ->
test 'simple function' ->
add = (x, y) -> x + y
add-curried = curry add
add-four = add-curried 4
eq 6 add-four 2
suite 'flip' ->
test 'minus op' ->
eq 10, (flip (-)) 5 15
suite 'fix' ->
test 'single arg' ->
eq 89, (fix (fib) -> (n) ->
| n <= 1 => 1
| otherwise => fib(n-1) + fib(n-2))(10)
test 'multi-arg variation' ->
eq 89, (fix (fib) -> (n, minus=0) ->
| (n - minus) <= 1 => 1
| otherwise => fib(n, minus+1) + fib(n, minus+2))(10)
suite 'over' ->
test 'basic' ->
f = (==) `over` (-> it)
ok f 2 2
ok not f 2 3
test 'with accessor function' ->
same-length = (==) `over` (.length)
ok same-length [1 2 3] [4 5 6]
ok not same-length [1 2] [4 5 6]
suite 'memoize' ->
spy = f = null
setup ->
spy := sinon.spy -> &
f := memoize spy
test 'only 1 call when using the same arguments' ->
[0 to 10].for-each -> f!
ok spy.called-once
test 'call again when using different arguments' ->
f \mung
f \mung
f '1,2'
f [1 2]
ok spy.called-thrice
test 'that the correct values are returned' ->
eq f(\mung), f(\mung)
eq f(\mung \face), f(\mung \face)
not-eq f(\mung), f(\mung \face)
================================================
FILE: test/List.ls
================================================
{
id
Num: {even, odd, floor, is-it-NaN}
List: {
each, map, filter, compact, reject, remove, partition, find,
head, first, tail, last, initial, empty,
reverse, difference, intersection, union, count-by, group-by,
fold, fold1, foldl, foldl1, foldr, foldr1, unfoldr, and-list, or-list,
any, all, unique, unique-by, sort, sort-with, sort-by, sum, product, mean, average,
concat, concat-map, flatten,
maximum, minimum, maximum-by, minimum-by,
scan, scan1, scanl, scanl1, scanr, scanr1,
slice, take, drop, split-at, take-while, drop-while, span, break-list,
zip, zip-with, zip-all, zip-all-with,
at, elem-index, elem-indices, find-index, find-indices,
}
} = require '..'
{strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert'
suite 'each' ->
test 'empty list as input' ->
deep-eq [], each id, []
test 'side effects affect input (and thus result)' ->
deep-eq [[1],[2]] each (.pop!), [[1 5] [2 6]]
test 'curried' ->
f = each (.pop!)
deep-eq [[1],[2]], f [[1 5] [2 6]]
suite 'map' ->
test 'empty list as input' ->
deep-eq [], map id, []
test 'mapping over array' ->
deep-eq [2 3 4], map (+ 1), [1 2 3]
test 'curried' ->
f = map (+ 1)
deep-eq [2 3 4], f [1 2 3]
suite 'compact' ->
test 'empty list as input' ->
deep-eq [], compact []
test 'compacting array' ->
deep-eq [1 true 'ha'], compact [0 1 false true '' 'ha']
suite 'filter' ->
test 'empty list as input' ->
deep-eq [], filter id, []
test 'filtering array' ->
deep-eq [2, 4], filter even, [1 to 5]
test 'filter on true returns original list' ->
deep-eq [1 2 3], filter (-> true), [1 2 3]
test 'filter on false returns empty list' ->
deep-eq [], filter (-> false), [1 2 3]
test 'curried' ->
f = filter even
deep-eq [2, 4], f [1 to 5]
suite 'reject' ->
test 'empty list as input' ->
deep-eq [], reject id, []
test 'reject list' ->
deep-eq [1 3 5], reject even, [1 to 5]
test 'reject on true returns empty list' ->
deep-eq [], reject (-> true), [1 2 3]
test 'reject on true returns original list' ->
deep-eq [1 2 3], reject (-> false), [1 2 3]
test 'curried' ->
f = reject even
deep-eq [1 3 5], f [1 to 5]
suite 'remove' ->
test 'empty list as input' ->
deep-eq [], remove 2, []
test 'basic' ->
deep-eq [1 3], remove 2, [1 2 3]
test 'multiple' ->
deep-eq [1 3 2], remove 2, [1 2 3 2]
test 'not there' ->
deep-eq [1 2 3], remove 5, [1 2 3]
test 'curried' ->
f = remove 2
deep-eq [1 3], f [1 2 3]
suite 'partition' ->
test 'empty list as input' ->
deep-eq [[],[]], partition id, []
test 'partition list' ->
deep-eq [[76 88 77 90],[49 58 43]], partition (>60), [49 58 76 43 88 77 90]
test 'partition on true returns original list as passing, empty list as failing' ->
deep-eq [[1 2 3],[]], partition (-> true), [1 2 3]
test 'partition on false returns empty list as failing, empty list as passing' ->
deep-eq [[], [1 2 3]], partition (-> false), [1 2 3]
test 'curried' ->
f = partition (>60)
deep-eq [[76 88 77 90],[49 58 43]], f [49 58 76 43 88 77 90]
suite 'find' ->
test 'empty list as input' ->
eq void, find id, []
test 'find from list' ->
eq 4, find even, [3 1 4 8 6]
test 'finding nothing when function always false' ->
eq void, find (-> false), [1 2 3]
test 'find first item when function always true' ->
eq 1, find (-> true), [1 2 3]
test 'curried' ->
f = find even
eq 4, f [3 1 4 8 6]
suite 'list portions' ->
list = [1 2 3 4 5]
suite 'head' ->
test 'empty list as input' ->
eq void, head []
test 'list' ->
eq 1, head list
test 'first as alias' ->
eq first, head
suite 'tail' ->
test 'empty list as input' ->
eq void, tail []
test 'list' ->
deep-eq [2 3 4 5], tail list
test 'one element list' ->
deep-eq [], tail [1]
suite 'last' ->
test 'empty list as input' ->
eq void, last []
test 'list' ->
eq 5, last list
test 'one element list' ->
eq 1, last [1]
suite 'initial' ->
test 'empty list as input' ->
eq void, initial []
test 'list' ->
deep-eq [1 2 3 4], initial list
test 'one element list' ->
deep-eq [], initial [1]
suite 'empty' ->
test 'empty list as input' ->
ok empty []
test 'non-empty list as input' ->
ok not empty [1]
suite 'reverse' ->
test 'empty list as input' ->
deep-eq [], reverse []
test 'reverse list, it is unmodified' ->
list = [1 2 3 4 5]
deep-eq [5 4 3 2 1], reverse list
deep-eq [1 2 3 4 5], list
suite 'unique' ->
test 'empty list as input' ->
deep-eq [], unique []
test 'unique list' ->
deep-eq [1,2,3,4,5,6], unique [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6]
test 'mixed string/num' ->
deep-eq ['1' 1 2 4 5], unique ['1' 1 2 4 5 5]
suite 'unique-by' ->
test 'empty list as input' ->
deep-eq [], unique-by id, []
test 'basic' ->
deep-eq [1,2,3,4,5,6], unique-by id, [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6]
test 'accessor' ->
deep-eq [[] [1 2 3] [4] [5 6]], unique-by (.length), [[], [1 2 3], [4], [5 6], [7], [8 9 10]]
test 'curried' ->
deep-eq [1,2,3,4,5,6], (unique-by id) [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6]
suite 'fold' ->
test 'empty list as input' ->
eq 0, fold (+), 0, []
test 'list as input' ->
eq 12, fold (+), 0, [1 2 3 6]
test 'foldl is alias' ->
eq fold, foldl
test 'curried' ->
f = fold (+)
eq 12, f 0, [1 2 3 6]
g = fold (+), 0
eq 12 g [1 2 3 6]
suite 'fold1' ->
test 'empty list as input' ->
eq void, fold1 (+), []
test 'list as input' ->
eq 12, fold1 (+), [1 2 3 6]
test 'foldl1 as alais' ->
eq fold1, foldl1
test 'curried' ->
f = fold1 (+)
eq 12, f [1 2 3 6]
suite 'foldr' ->
test 'empty list as input' ->
eq 0, foldr (+), 0, []
test 'list as input' ->
eq 7, foldr (-), 9, [1 2 3 4]
eq 'abcde', foldr (+), 'e', <[ a b c d ]>
test 'curried' ->
f = foldr (-)
eq 7, f 9, [1 2 3 4]
g = foldr (-), 9
eq 7, g [1 2 3 4]
suite 'foldr1' ->
test 'empty list as input' ->
eq void, foldr1 (+), []
test 'list as input' ->
eq 7, foldr1 (-), [1 2 3 4 9]
eq 'abcde', foldr1 (+), <[ a b c d e ]>
test 'curried' ->
f = foldr1 (-)
eq 7, f [1 2 3 4 9]
suite 'unfoldr' ->
test 'complex case' ->
deep-eq [10,9,8,7,6,5,4,3,2,1], unfoldr (-> if it == 0 then null else [it, it - 1]), 10
test 'returning null right away results in a one item list' ->
deep-eq [], unfoldr (-> null), 'a'
test 'curried' ->
f = unfoldr (-> if it == 0 then null else [it, it - 1])
deep-eq [10,9,8,7,6,5,4,3,2,1], f 10
suite 'concat' ->
test 'empty list as input' ->
deep-eq [], concat []
test 'multiple lists' ->
deep-eq [1,2,3,4,5,6], concat [[1 2] [3 4] [5 6]]
suite 'concat-map' ->
test 'empty list as input' ->
deep-eq [], concat-map id, []
test 'using mapping and concatinating' ->
deep-eq [1,1,2,1,2,3], concat-map (-> [1 to it]), [1 2 3]
test 'curried' ->
f = concat-map (-> [1 to it])
deep-eq [1,1,2,1,2,3], f [1 2 3]
suite 'flatten' ->
test 'empty list as input' ->
deep-eq [], flatten []
test 'nested lists as input' ->
deep-eq [1,2,3,4,5], flatten [1, [[2], 3], [4, [[5]]]]
test 'lists with strings' ->
deep-eq ['a','b','c','d','e'], flatten ['a', [['b'], 'c'], ['d', [['e']]]]
suite 'difference' ->
test 'empty list(s) as input' ->
deep-eq [], difference []
deep-eq [], difference [] []
test 'subtract nothing' ->
deep-eq [1 2 3], difference [1 2 3]
deep-eq [1 2 3], difference [1 2 3] []
test 'subtract single element' ->
deep-eq [2 3], difference [1 2 3] [1]
test 'subtract multiple elements' ->
deep-eq [1 3 4], difference [1 2 3 4 5] [5 2 10] [9]
suite 'intersection' ->
test 'empty list(s) as input' ->
deep-eq [], intersection []
deep-eq [], intersection [] []
test 'no common elements' ->
deep-eq [],intersection [2 3] [9 8] [12 1] [99]
test 'some common elements' ->
deep-eq [1 2], intersection [1 2 3] [101 2 1 10] [2 1] [-1 0 1 2]
test 'all common elements' ->
deep-eq [1 2 3], intersection [1 2 3] [2 1 3] [3 1 2]
suite 'union' ->
test 'empty list(s) as input' ->
deep-eq [], union []
deep-eq [], union [] []
test 'list and empty list' ->
deep-eq [1 2 3], union [1 2 3] []
test 'with various' ->
deep-eq [1 5 7 3], union [1 5 7] [3 5] []
suite 'count-by' ->
test 'empty list as input' ->
deep-eq {}, count-by id, []
test 'list of numbers' ->
deep-eq {4: 1, 6: 2}, count-by floor, [4.2, 6.1, 6.4]
test 'list of strings' ->
deep-eq {3: 2, 5: 1}, count-by (.length), <[ one two three ]>
test 'curried' ->
f = count-by floor
deep-eq {4: 1, 6: 2}, f [4.2, 6.1, 6.4]
suite 'group-by' ->
test 'empty list as input' ->
deep-eq {}, group-by id, []
test 'list of numbers' ->
deep-eq {4: [4.2], 6: [6.1 6.4]}, group-by floor, [4.2, 6.1, 6.4]
test 'list of strings' ->
deep-eq {3: <[ one two ]>, 5: <[ three ]>}, group-by (.length), <[ one two three ]>
test 'curried' ->
f = group-by floor
deep-eq {4: [4.2], 6: [6.1 6.4]}, f [4.2, 6.1, 6.4]
suite 'and-list' ->
test 'empty list as input' ->
ok and-list []
test 'true' ->
ok and-list [true, 2 + 2 == 4]
test 'false' ->
ok not and-list [true true false true]
suite 'or-list' ->
test 'empty list as input' ->
ok not or-list []
test 'true' ->
ok or-list [false false false true false]
test 'false' ->
ok not or-list [false, 2 + 2 == 3]
suite 'any' ->
test 'empty list as input' ->
ok not any id, []
test 'true' ->
ok any even, [1 4 3]
test 'false' ->
ok not any even, [1 3 7 5]
test 'curried' ->
f = any even
ok f [1 4 3]
suite 'all' ->
test 'empty list as input' ->
ok all even, []
test 'true' ->
ok all even, [2 4 6]
test 'false' ->
ok not all even, [2 5 6]
test 'curried' ->
f = all even
ok f [2 4 6]
suite 'sort' ->
test 'empty list as input' ->
deep-eq [], sort []
test 'single digit numbers' ->
deep-eq [1,2,3,4,5,6], sort [3 1 5 2 4 6]
test 'multi digit numbers' ->
deep-eq [2,5,6,12,334,4999], sort [334 12 5 2 4999 6]
test 'same digits' ->
deep-eq [1 2 2 2 3], sort [2 3 2 1 2]
suite 'sort-with' ->
f = (x, y) ->
| x.length > y.length => 1
| x.length < y.length => -1
| otherwise => 0
test 'empty list as input' ->
deep-eq [], sort-with id, []
test 'complex case' ->
deep-eq ['one','two','three'], sort-with f, <[ three one two ]>
test 'curried' ->
g = sort-with f
deep-eq ['one','two','three'], g <[ three one two ]>
suite 'sort-by' ->
arr =
'hey'
'a'
'there'
'hey'
'ha'
test 'empty list as input' ->
deep-eq [], sort-by id, []
test 'complex case' ->
deep-eq ['a', 'ha', 'hey', 'hey', 'there'], sort-by (.length), arr
test 'curried' ->
f = sort-by (.length)
deep-eq ['a', 'ha', 'hey', 'hey', 'there'], f arr
suite 'sum' ->
test 'empty list as input' ->
eq 0, sum []
test 'list as input' ->
eq 10, sum [1 2 3 4]
test 'negative numbers' ->
eq -2, sum [1 -2 3 -4]
suite 'product' ->
test 'empty list as input' ->
eq 1, product []
test 'list as input' ->
eq 24, product [1 2 3 4]
test 'negative numbers' ->
eq -6, product [1 -2 3]
suite 'mean' ->
test 'empty list as input' ->
ok is-it-NaN mean []
test 'list as input' ->
eq 4, mean [2 3 4 5 6]
test 'average as alias' ->
eq mean, average
suite 'maximum' ->
test 'empty list as input' ->
eq void, maximum []
test 'single element list' ->
eq 1, maximum [1]
test 'multi element list' ->
eq 6, maximum [1 2 6 4 5]
suite 'minimum' ->
test 'empty list as input' ->
eq void, minimum []
test 'single element list' ->
eq 1, minimum [1]
test 'multi element list' ->
eq 2, minimum [4 3 2 6 9]
test 'list of strings' ->
eq 'a', minimum ['c', 'e', 'a', 'd', 'b']
suite 'maximum-by' ->
test 'empty list as input' ->
eq void, maximum-by id, []
test 'single element list' ->
eq 1, maximum-by id, [1]
test 'multi element list' ->
eq 'long-string', maximum-by (.length), <[ hi there I am a really long-string ]>
test 'curried' ->
eq 2, (maximum-by id) [1 2 0]
suite 'minimum-by' ->
test 'empty list as input' ->
eq void, minimum-by id, []
test 'single element list' ->
eq 1, minimum-by id, [1]
test 'multi element list' ->
eq 'I', minimum-by (.length), <[ hi there I am a really long-string ]>
test 'curried' ->
eq 0, (minimum-by id) [1 2 0]
suite 'scan' ->
test 'empty list as input' ->
deep-eq [null], scan id, null, []
test 'complex case' ->
deep-eq [4,9,20,43], scan ((x, y) -> 2 * x + y), 4, [1 2 3]
test 'scanl as alias' ->
eq scan, scanl
test 'curried' ->
f = scan ((x, y) -> 2 * x + y)
deep-eq [4,9,20,43], f 4, [1 2 3]
g = scan ((x, y) -> 2 * x + y), 4
deep-eq [4,9,20,43], g [1 2 3]
suite 'scan1' ->
test 'empty list as input' ->
deep-eq void, scan1 id, []
test 'complex case' ->
deep-eq [1,3,6,10], scan1 (+), [1 2 3 4]
test 'scanl1 as alias' ->
eq scan1, scanl1
test 'curried' ->
f = scan1 (+)
deep-eq [1,3,6,10], f [1 2 3 4]
suite 'scanr' ->
test 'empty list as input' ->
deep-eq [null], scanr id, null, []
test 'complex case' ->
deep-eq [15,14,12,9,5], scanr (+), 5, [1 2 3 4]
test 'curried' ->
f = scanr (+)
deep-eq [15,14,12,9,5], f 5, [1 2 3 4]
g = scanr (+), 5
deep-eq [15,14,12,9,5], g [1 2 3 4]
suite 'scanr1' ->
test 'empty list as input' ->
deep-eq void, scanr1 id, []
test 'complex case' ->
deep-eq [10,9,7,4], scanr1 (+), [1 2 3 4]
test 'curried' ->
f = scanr1 (+)
deep-eq [10,9,7,4], f [1 2 3 4]
suite 'slice' ->
test 'zero to zero' ->
deep-eq [], slice 0 0 [1 2 3 4 5]
test 'empty lsit as input' ->
deep-eq [], slice 2 3 []
test 'parts' ->
deep-eq [3 4], slice 2 4 [1 2 3 4 5]
test 'curried' ->
f = slice 2
deep-eq [3 4], f 4 [1 2 3 4 5]
g = slice 2 4
deep-eq [3 4], g [1 2 3 4 5]
suite 'take' ->
test 'empty list as input' ->
deep-eq [], take 3 []
test 'zero on list' ->
deep-eq [], take 0 [1 2 3 4 5]
test 'negative number' ->
deep-eq [], take -1 [1 2 3 4 5]
test 'too big number' ->
deep-eq [1 2 3 4 5], take 9 [1 2 3 4 5]
test 'list' ->
deep-eq [1 2 3], take 3 [1 2 3 4 5]
test 'curried' ->
f = take 3
deep-eq [1 2 3], f [1 2 3 4 5]
suite 'drop' ->
test 'empty list as input' ->
deep-eq [], drop 3 []
test 'zero on list' ->
deep-eq [1 2 3 4 5], drop 0 [1 2 3 4 5]
test 'negative number' ->
deep-eq [1 2 3 4 5], drop -1 [1 2 3 4 5]
test 'too big number' ->
deep-eq [], drop 9 [1 2 3 4 5]
test 'list' ->
deep-eq [4 5], drop 3 [1 2 3 4 5]
test 'curried' ->
f = drop 3
deep-eq [4 5], f [1 2 3 4 5]
suite 'split-at' ->
test 'empty list as input' ->
deep-eq [[], []], split-at 3 []
test 'zero on list' ->
deep-eq [[], [1 2 3 4 5]], split-at 0 [1 2 3 4 5]
test 'negative number' ->
deep-eq [[], [1 2 3 4 5]], split-at -1 [1 2 3 4 5]
test 'too big number' ->
deep-eq [[1 2 3 4 5], []], split-at 9 [1 2 3 4 5]
test 'list' ->
deep-eq [[1 2 3], [4 5]], split-at 3 [1 2 3 4 5]
test 'curried' ->
f = split-at 3
deep-eq [[1 2 3], [4 5]], f [1 2 3 4 5]
suite 'take-while' ->
test 'empty list as input' ->
deep-eq [], take-while id, []
test 'list' ->
deep-eq [1 3 5], take-while odd, [1 3 5 4 8 7 9]
test 'all pass' ->
deep-eq [42], take-while (== 42), [42]
deep-eq [2 4 8], take-while even, [2 4 8]
test 'all fail' ->
deep-eq [], take-while (== 7), [42]
deep-eq [], take-while odd, [2 4 8]
test 'curried' ->
f = take-while odd
deep-eq [1 3 5], f [1 3 5 4 8 7 9]
suite 'drop-while' ->
test 'empty list as input' ->
deep-eq [], drop-while id, []
test 'list' ->
deep-eq [7 9 10], drop-while even, [2 4 6 7 9 10]
test 'all pass' ->
deep-eq [], drop-while (== 42), [42]
deep-eq [], drop-while even, [2 4 8]
test 'all-fail' ->
deep-eq [42], drop-while (== 7), [42]
deep-eq [2 4 8], drop-while odd, [2 4 8]
test 'curried' ->
f = drop-while even
deep-eq [7 9 10], f [2 4 6 7 9 10]
suite 'span' ->
test 'empty list as input' ->
deep-eq [[], []], span id, []
test 'list' ->
deep-eq [[2 4 6], [7 9 10]], span even, [2 4 6 7 9 10]
test 'curried' ->
f = span even
deep-eq [[2 4 6], [7 9 10]], f [2 4 6 7 9 10]
suite 'break-list' ->
test 'empty list as input' ->
deep-eq [[], []], break-list id, []
test 'list' ->
deep-eq [[1 2], [3 4 5]], break-list (== 3), [1 2 3 4 5]
test 'curried' ->
f = break-list (== 3)
deep-eq [[1 2], [3 4 5]], f [1 2 3 4 5]
suite 'zip' ->
test 'empty lists as input' ->
deep-eq [], zip [] []
test 'equal length lists' ->
deep-eq [[1 4], [2 5]], zip [1 2] [4 5]
test 'first list shorter' ->
deep-eq [[1 4], [2 5]], zip [1 2] [4 5 6]
test 'second list shorter' ->
deep-eq [[1 4], [2 5]], zip [1 2 3] [4 5]
test 'curried' ->
f = zip [1 2]
deep-eq [[1 4], [2 5]], f [4 5]
suite 'zip-with' ->
test 'empty lists as input' ->
deep-eq [], zip-with id, [], []
test 'equal length lists' ->
deep-eq [4 4 4], zip-with (+), [1 2 3], [3 2 1]
test 'first list shorter' ->
deep-eq [5 7], zip-with (+), [1 2], [4 5 6]
test 'second list shorter' ->
deep-eq [5 7], zip-with (+), [1 2 3] [4 5]
test 'curried' ->
f = zip-with (+)
deep-eq [4 4 4], f [1 2 3], [3 2 1]
g = zip-with (+), [1 2 3]
deep-eq [4 4 4], g [3 2 1]
suite 'zip-all' ->
test 'no lists as input' ->
deep-eq [], zip-all!
test 'empty lists as input' ->
deep-eq [], zip-all [] [] []
test 'equal length lists' ->
deep-eq [[1 4 7], [2 5 8], [3 6 9]], zip-all [1 2 3] [4 5 6] [7 8 9]
test 'first list shorter' ->
deep-eq [[1 4 7], [2 5 8]], zip-all [1 2] [4 5 6] [7 8 9]
test 'second list shorter' ->
deep-eq [[1 4 7], [2 5 8]], zip-all [1 2 3] [4 5] [7 8 9]
test 'third list shorter' ->
deep-eq [[1 4 7], [2 5 8]], zip-all [1 2 3] [4 5 6] [7 8]
suite 'zip-all-with' ->
test 'nothing as input' ->
deep-eq [], zip-all-with!
test 'no lists as input' ->
deep-eq [], zip-all-with id
test 'empty lists as input' ->
deep-eq [], zip-all-with id, [], []
test 'equal length lists' ->
deep-eq [5 5 5], zip-all-with (-> &0 + &1 + &2), [1 2 3], [3 2 1], [1 1 1]
test 'first list shorter' ->
deep-eq [5 7], zip-all-with (+), [1 2], [4 5 6]
test 'second list shorter' ->
deep-eq [5 7], zip-all-with (+), [1 2 3] [4 5]
suite 'at' ->
test 'empty list as input' ->
eq void, at 0, []
test 'positive n' ->
eq 2, at 1, [1 2 3]
test 'negative n' ->
eq 3, at -1, [1 2 3]
test 'not defined at index' ->
eq void, at 10, [1 2 3]
test 'curried' ->
eq 2, (at 1) [1 2 3]
suite 'elem-index' ->
test 'empty list as input' ->
eq void, elem-index 2, []
test 'basic' ->
eq 1, elem-index 2, [1 2 3]
test 'multiple' ->
eq 1, elem-index 2, [1 2 3 2 1]
test 'not there' ->
eq void, elem-index 5, [1 2 3]
test 'curried' ->
eq 1, (elem-index 2) [1 2 3]
suite 'elem-indices' ->
test 'empty list as input' ->
deep-eq [], elem-indices 2, []
test 'single' ->
deep-eq [1], elem-indices 2, [1 2 3]
test 'multiple' ->
deep-eq [1, 3], elem-indices 2, [1 2 3 2 1]
test 'not there' ->
deep-eq [], elem-indices 5, [1 2 3]
test 'curried' ->
deep-eq [1], (elem-indices 2) [1 2 3]
suite 'find-index' ->
test 'empty list as input' ->
eq void, find-index id, []
test 'basic' ->
eq 1, find-index (== 2), [1 2 3]
test 'multiple' ->
eq 1, find-index even, [1 2 3 4]
test 'not there' ->
eq void, find-index odd, [2 4 6]
test 'curried' ->
eq 1, (find-index (== 2)) [1 2 3]
suite 'find-indices' ->
test 'empty list as input' ->
deep-eq [], find-indices id, []
test 'basic' ->
deep-eq [1], find-indices (== 2), [1 2 3]
test 'multiple' ->
deep-eq [1, 3], find-indices even, [1 2 3 4]
test 'not there' ->
deep-eq [], find-indices odd, [2 4 6]
test 'curried' ->
deep-eq [1], (find-indices (== 2)) [1 2 3]
================================================
FILE: test/Num.ls
================================================
{
max, min, negate, abs, signum, quot, rem, div, mod, recip,
pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2,
truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm,
} = require '..'
{strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert'
suite 'max' ->
test 'numbers' ->
eq 3, max 3 3
eq 3, max 2 3
eq 3, max 3 2
test 'characters' ->
eq \b, max \a \b
test 'curried' ->
f = max 2
eq 3, f 3
suite 'min' ->
test 'numbers' ->
eq 0, min 9 0
test 'characters' ->
eq \a, min \a \b
test 'curried' ->
f = min 9
eq 0, f 0
suite 'negate' ->
test 'zero' ->
eq -0, negate 0
test 'negative number' ->
eq -2, negate 2
test 'positive number' ->
eq 3, negate -3
suite 'abs' ->
test 'zero' ->
eq 0, abs 0
test 'negative number' ->
eq 4 abs -4
test 'positive number' ->
eq 4 abs 4
suite 'signum' ->
test 'zero' ->
eq 0 signum 0
test 'negative number' ->
eq -1 signum -5.3
test 'positive number' ->
eq 1 signum 8
suite 'quot' ->
test 'simple' ->
eq -6, quot -20 3
test 'curried' ->
f = quot -20
eq -6, f 3
suite 'rem' ->
test 'simple' ->
eq -2, rem -20 3
test 'curried' ->
f = rem -20
eq -2, f 3
suite 'div' ->
test 'simple' ->
eq -7, div -20 3
test 'curried' ->
f = div -20
eq -7, f 3
suite 'mod' ->
test 'simple' ->
eq 1, mod -20 3
test 'curried' ->
f = mod -20
eq 1, f 3
suite 'recip' ->
test 'zero' ->
eq Infinity, recip 0
test 'larger than 1' ->
eq 0.5, recip 2
test 'between 0 and 1' ->
eq 2, recip 0.5
suite 'pi' ->
test 'constant' ->
eq 3.141592653589793, pi
suite 'tau' ->
test 'constant' ->
eq 6.283185307179586, tau
suite 'exp' ->
test 'simple' ->
eq 2.718281828459045, exp 1
suite 'sqrt' ->
test 'negative numbers' ->
ok is-it-NaN sqrt -1
test 'simple' ->
eq 2 sqrt 4
suite 'ln' ->
test 'simple' ->
eq 0.6931471805599453, ln 2
suite 'pow' ->
test 'simple' ->
eq 4, pow 2 2
eq 4, pow -2 2
test 'with negative numbers' ->
eq 0.25, pow 2 -2
test 'between one and zero' ->
eq 4, pow 16 0.5
test 'curried' ->
f = pow 2
eq 4, f 2
suite 'sin' ->
test 'zero' ->
eq 0, sin 0
test 'pi/2' ->
eq 1, sin pi/2
suite 'tan' ->
test 'zero' ->
eq 0, tan 0
suite 'cos' ->
test 'zero' ->
eq 1, cos 0
test 'pi' ->
eq -1, cos pi
suite 'acos' ->
test 'number' ->
eq 1.4706289056333368, acos 0.1
suite 'asin' ->
test 'number' ->
eq 1.5707963267948966, asin 1
suite 'atan' ->
test 'number' ->
eq 0.7853981633974483, atan 1
suite 'atan2' ->
test 'number' ->
eq 0.4636476090008061, atan2 1 2
test 'curried' ->
f = atan2 1
eq 0.4636476090008061, f 2
suite 'truncate' ->
test 'zero' ->
eq 0, truncate 0
test 'positive number' ->
eq 1 truncate 1.5
test 'negative number' ->
eq -1 truncate -1.5
suite 'round' ->
test 'up' ->
eq 1 round 0.6
eq 1 round 0.5
test 'down' ->
eq 0 round 0.4
suite 'ceiling' ->
test 'zero' ->
eq 0, ceiling 0
test 'positive number' ->
eq 1, ceiling 0.1
test 'negative number' ->
eq -0, ceiling -0.9
suite 'floor' ->
test 'zero' ->
eq 0, floor 0
test 'positive number' ->
eq 0, floor 0.9
test 'negative number' ->
eq -1, floor -0.1
suite 'is-it-NaN' ->
test 'true' ->
ok is-it-NaN Math.sqrt -1
test 'false' ->
ok not is-it-NaN '0'
suite 'even' ->
test 'true' ->
ok even 0
ok even -2
test 'false' ->
ok not even 7
suite 'odd' ->
test 'true' ->
ok odd 3
test 'false' ->
ok not odd -4
ok not odd 0
suite 'gcd' ->
test 'some numbers' ->
eq 6, gcd 12 18
test 'curried' ->
f = gcd 12
eq 6, f 18
suite 'lcm' ->
test 'some numbers' ->
eq 36, lcm 12 18
test 'curried' ->
f = lcm 12
eq 36, f 18
================================================
FILE: test/Obj.ls
================================================
{
id
Obj: {
values, keys,
pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists,
empty, each, map, filter, compact, reject, partition, find,
}
} = require '..'
{strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert'
suite 'values' ->
test 'empty object as input' ->
deep-eq [], values {}
test 'object as input' ->
deep-eq [1 2 3], values sadf: 1, asdf: 2, fdas: 3
suite 'keys' ->
test 'empty object as input' ->
deep-eq [], keys {}
test 'object as input' ->
deep-eq <[ sadf asdf fdas ]>, keys sadf: 1, asdf: 2, fdas: 3
suite 'pairs-to-obj' ->
test 'empty list as input' ->
deep-eq {}, pairs-to-obj []
test 'pairs as input' ->
deep-eq {a: 'b', c: 'd', e: 1}, pairs-to-obj [['a' 'b'] ['c' 'd'] ['e' 1]]
suite 'obj-to-pairs' ->
test 'empty object as input' ->
deep-eq [], obj-to-pairs {}
test 'object as input' ->
deep-eq [['a' 'b'] ['c' 'd'] ['e' 1]], obj-to-pairs {a: 'b', c: 'd', e: 1}
suite 'lists-to-obj' ->
test 'empty lists as input' ->
deep-eq {}, lists-to-obj [] []
test 'two lists of the same length' ->
deep-eq {a: 1, b: 2, c: 3}, lists-to-obj <[ a b c ]> [1 2 3]
test 'first list is shorter' ->
deep-eq {a: 1, b: 2}, lists-to-obj <[ a b ]> [1 2 3]
test 'first list is longer' ->
deep-eq {a: 1, b: 2, c: void}, lists-to-obj <[ a b c ]> [1 2]
test 'curried' ->
f = lists-to-obj <[ a b c ]>
deep-eq {a: 1, b: 2, c: 3}, f [1 2 3]
suite 'obj-to-lists' ->
test 'empty object as input' ->
deep-eq [[], []], obj-to-lists {}
test 'two lists of the same length' ->
deep-eq [<[ a b c ]>, [1 2 3]], obj-to-lists {a: 1, b: 2, c: 3}
suite 'empty' ->
test 'empty object as input' ->
ok empty {}
test 'non-empty object as input' ->
ok not empty {x: 1}
suite 'each' ->
test 'empty object as input' ->
deep-eq {}, each id, {}
test 'iterate over object values' ->
count = 4
each (-> count += it), {a: 1, b: 2, c: 3}
eq 10 count
test 'curried' ->
count = 4
f = each (-> count += it)
f {a: 1, b: 2, c: 3}
eq 10 count
suite 'map' ->
test 'empty object as input' ->
deep-eq {}, map id, {}
test 'mapping over object' ->
deep-eq {a:2, b:4}, map (* 2), {a:1, b:2}
test 'curried' ->
f = map (* 2)
deep-eq {a:2, b:4}, f {a:1, b:2}
suite 'compact' ->
test 'empty object as input' ->
deep-eq {}, compact {}
test 'compacting object' ->
deep-eq {b: 1, e: 'ha'}, compact {a: 0, b: 1, c: false, d: '', e: 'ha'}
suite 'filter' ->
test 'empty object as input' ->
deep-eq {}, filter id, {}
test 'filtering object' ->
deep-eq {b: 2}, filter (== 2), {a:1, b:2}
test 'curried' ->
f = filter (== 2)
deep-eq {b: 2}, f {a:1, b:2}
suite 'reject' ->
test 'empty object as input' ->
deep-eq {}, reject id, {}
test 'reject object' ->
deep-eq {a: 1}, reject (==2), {a:1, b:2}
test 'curried' ->
f = reject (== 2)
deep-eq {a: 1}, f {a:1, b:2}
suite 'partition' ->
test 'empty object as input' ->
deep-eq [{}, {}], partition id, {}
test 'partition object' ->
deep-eq [{b: 2}, {a: 1, c: 3}], partition (==2), {a:1, b:2, c:3}
test 'curried' ->
f = partition (== 2)
deep-eq [{b: 2}, {a: 1, c: 3}], f {a:1, b:2, c:3}
suite 'find' ->
test 'empty object as input' ->
eq void, find id, {}
test 'find from object' ->
eq 2, find (==2), {a:1, b:2}
test 'curried' ->
f = find (== 2)
eq 2, f {a:1, b:2}
================================================
FILE: test/Str.ls
================================================
{
id
Str: {
split, join, lines, unlines, words, unwords, chars, unchars, empty, reverse
repeat, capitalize, camelize, dasherize
slice, take, drop, split-at, take-while, drop-while, span, break-str
}
} = require '..'
{strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert'
suite 'split' ->
test 'empty string as input' ->
deep-eq [], split '' ''
test 'string of some length' ->
deep-eq <[ 1 2 3 ]>, split '|' '1|2|3'
test 'curried' ->
f = split '|'
deep-eq <[ 1 2 3 ]>, f '1|2|3'
suite 'join' ->
test 'empty list as input' ->
eq '' join '', []
test 'list as input' ->
eq '1,2,3', join ',' [1 2 3]
test 'empty string as seperator' ->
eq '123', join '' [1 2 3]
test 'curried' ->
f = join ','
eq '1,2,3', f [1 2 3]
suite 'lines' ->
test 'empty string as input' ->
deep-eq [], lines ''
test 'string as input' ->
deep-eq <[ one two three ]>, lines 'one\ntwo\nthree'
suite 'unlines' ->
test 'empty array as input' ->
eq '', unlines []
test 'array as input' ->
eq 'one\ntwo\nthree', unlines [\one \two \three]
suite 'words' ->
test 'empty string as input' ->
deep-eq [], words ''
test 'string as input' ->
deep-eq <[ what is this ]>, words 'what is this'
suite 'unwords' ->
test 'empty array as input' ->
eq '', unwords []
test 'array as input' ->
eq 'what is this', unwords [\what \is \this]
suite 'chars' ->
test 'empty string as input' ->
deep-eq [], chars ''
test 'string as input' ->
deep-eq <[ h e l l o ]>, chars 'hello'
suite 'unchars' ->
test 'empty array as input' ->
eq '', unchars []
test 'array as input' ->
eq 'there', unchars ['t', 'h', 'e', 'r', 'e']
suite 'empty' ->
test 'empty string as input' ->
ok empty ''
test 'string as input' ->
ok not empty 'a'
suite 'reverse' ->
test 'empty string as input' ->
eq '', reverse ''
test 'a string' ->
eq 'cba', reverse 'abc'
eq 'olleh', reverse 'hello'
suite 'repeat' ->
test 'zero times' ->
eq '' repeat 0 'hi'
test 'empty string as input' ->
eq '', repeat 2 ''
test 'a string several times' ->
eq 'aa', repeat 2 'a'
eq 'hihihi', repeat 3 'hi'
eq 'hihihihihihihihihihi', repeat 10 'hi'
test 'curried' ->
f = repeat 2
eq 'aa', f 'a'
suite 'capitalize' ->
test 'empty string as input' ->
eq '', capitalize ''
test 'basic' ->
eq 'Foo', capitalize 'foo'
suite 'camelize' ->
test 'empty string as input' ->
eq '', camelize ''
test 'no change' ->
eq 'fooBar', camelize 'fooBar'
test 'dashes' ->
eq 'fooBar', camelize 'foo-bar'
test 'underscore' ->
eq 'fooBar', camelize 'foo_bar'
test 'ending dash' ->
eq 'fooBar', camelize 'foo-bar-'
test 'more than one' ->
eq 'fooBar', camelize 'foo--bar'
suite 'dasherize' ->
test 'empty string as input' ->
eq '', dasherize ''
test 'no change' ->
eq 'foo-bar', dasherize 'foo-bar'
test 'basic' ->
eq 'foo-bar', dasherize 'fooBar'
test 'with numbers' ->
eq 'f1-bar', dasherize 'f1Bar'
test 'repeated capitals' ->
eq 'set-JSON', dasherize 'setJSON'
test 'starting with capital' ->
eq 'foo-bar', dasherize 'FooBar'
test 'starting with repeated capitals' ->
eq 'JSON-get', dasherize 'JSONget'
suite 'slice' ->
test 'zero to zero' ->
eq '', slice 0 0 'hello'
test 'empty string as input' ->
eq '', slice 2 3 ''
test 'parts' ->
eq 'll', slice 2 4 'hello'
test 'curried' ->
f = slice 2
eq 'll', f 4 'hello'
g = slice 2 4
eq 'll', g 'hello'
suite 'take' ->
test 'empty string as input' ->
eq '', take 3 ''
test 'zero on string' ->
eq '', take 0 'abcde'
test 'string' ->
eq 'ab', take 2 'abcde'
test 'curried' ->
f = take 2
eq 'ab', f 'abcde'
suite 'drop' ->
test 'empty string as input' ->
eq '', drop 3 ''
test 'zero on string' ->
eq 'abcde', drop 0 'abcde'
test 'string' ->
eq 'cde', drop 2 'abcde'
test 'curried' ->
f = drop 2
eq 'cde', f 'abcde'
suite 'split-at' ->
test 'empty string as input' ->
deep-eq ['', ''], split-at 3 ''
test 'zero on string' ->
deep-eq ['', 'abcde'], split-at 0 'abcde'
test 'string' ->
deep-eq ['ab', 'cde'], split-at 2 'abcde'
test 'curried' ->
f = split-at 2
deep-eq ['ab', 'cde'], f 'abcde'
suite 'take-while' ->
test 'empty string as input' ->
eq '', take-while id, ''
test 'string' ->
eq 'mmmmm', take-while (is 'm'), 'mmmmmhmm'
test 'curried' ->
f = take-while (is 'm')
eq 'mmmmm', f 'mmmmmhmm'
suite 'drop-while' ->
test 'empty string as input' ->
eq '', drop-while id, ''
test 'string' ->
eq 'hmm', drop-while (is \m), 'mmmmmhmm'
test 'curried' ->
f = drop-while (is \m)
eq 'hmm', f 'mmmmmhmm'
suite 'span' ->
test 'empty string as input' ->
deep-eq ['', ''], span id, ''
test 'string' ->
deep-eq ['mmmmm', 'hmm'], span (is \m), 'mmmmmhmm'
test 'curried' ->
f = span (is \m)
deep-eq ['mmmmm', 'hmm'], f 'mmmmmhmm'
suite 'break-str' ->
test 'empty string as input' ->
deep-eq ['', ''], break-str id, ''
test 'string' ->
deep-eq ['mmmmm', 'hmm'], break-str (is \h), 'mmmmmhmm'
test 'curried' ->
f = break-str (is \h)
deep-eq ['mmmmm', 'hmm'], f 'mmmmmhmm'
================================================
FILE: test/browser.html
================================================
<!doctype html>
<script src="../browser/prelude-browser.js"></script>
<script>
window.prelude = require('prelude-ls');
</script>
================================================
FILE: test/index.ls
================================================
{id, is-type, replicate, VERSION} = require '..'
{strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert'
suite 'library' ->
test 'version' ->
eq VERSION, (require '../package.json').version
suite 'id' ->
test 'number' ->
eq 5, id 5
test 'object is the same' ->
obj = {}
eq obj, id obj
suite 'is-type' ->
test 'literals' ->
ok is-type 'Undefined' void
ok is-type 'Boolean' true
ok is-type 'Number' 1
ok is-type 'Number' 1.2
ok is-type 'String' 'asdfa'
ok is-type 'Object' {}
ok is-type 'Array' []
ok not is-type 'Boolean' 1
test 'constructors' ->
ok is-type 'Date' new Date
test 'classes' ->
class A
ok is-type 'Object' new A
test 'curried' ->
f = is-type 'Boolean'
ok f true
suite 'replicate' ->
test 'zero as input' ->
deep-eq [], replicate 0 0
deep-eq [], replicate 0 'a'
test 'number as input' ->
deep-eq [3,3,3,3], replicate 4 3
test 'string as input' ->
deep-eq <[ a a a a ]>, replicate 4 'a'
test 'curried' ->
f = replicate 4
deep-eq [3,3,3,3], f 3
gitextract_3gmtmqye/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── Makefile
├── README.md
├── browser/
│ ├── prelude-browser-min.js
│ └── prelude-browser.js
├── lib/
│ ├── Func.js
│ ├── List.js
│ ├── Num.js
│ ├── Obj.js
│ ├── Str.js
│ └── index.js
├── package.json
├── package.json.ls
├── preroll.ls
├── src/
│ ├── Func.ls
│ ├── List.ls
│ ├── Num.ls
│ ├── Obj.ls
│ ├── Str.ls
│ └── index.ls
└── test/
├── Func.ls
├── List.ls
├── Num.ls
├── Obj.ls
├── Str.ls
├── browser.html
└── index.ls
SYMBOL INDEX (32 symbols across 8 files)
FILE: browser/prelude-browser-min.js
function l (line 6) | function l(u,o,a){function f(t,n){if(!o[t]){if(!u[t]){var r="function"==...
function l (line 8) | function l(t,e){var i,u=function(r){return t.length>1?function(){var n=r...
function s (line 10) | function s(){var n,r,t,e=[];for(n=0,t=(r=i).length;n<t;++n){a=r[n];e.pus...
function bn (line 10) | function bn(t,e){var i,u=function(r){return t.length>1?function(){var n=...
function Mn (line 10) | function Mn(n,r){var t=-1,e=r.length>>>0;while(++t<e)if(n===r[t])return ...
function zn (line 10) | function zn(){var t=arguments;return function(){var n,r;r=t[0].apply(thi...
function kn (line 10) | function kn(n){return!n}
function S (line 12) | function S(t,e){var i,u=function(r){return t.length>1?function(){var n=r...
function m (line 14) | function m(t,e){var i,u=function(r){return t.length>1?function(){var n=r...
function d (line 16) | function d(t,e){var i,u=function(r){return t.length>1?function(){var n=r...
function p (line 18) | function p(t,e){var i,u=function(r){return t.length>1?function(){var n=r...
FILE: browser/prelude-browser.js
function r (line 7) | function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==...
function curry$ (line 64) | function curry$(f, bound){
function fn$ (line 634) | function fn$(){
function curry$ (line 764) | function curry$(f, bound){
function in$ (line 777) | function in$(x, xs){
function compose$ (line 782) | function compose$() {
function not$ (line 793) | function not$(x){ return !x; }
function curry$ (line 912) | function curry$(f, bound){
function curry$ (line 1067) | function curry$(f, bound){
function curry$ (line 1160) | function curry$(f, bound){
function curry$ (line 1339) | function curry$(f, bound){
FILE: lib/Func.js
function curry$ (line 57) | function curry$(f, bound){
FILE: lib/List.js
function fn$ (line 557) | function fn$(){
function curry$ (line 687) | function curry$(f, bound){
function in$ (line 700) | function in$(x, xs){
function compose$ (line 705) | function compose$() {
function not$ (line 716) | function not$(x){ return !x; }
FILE: lib/Num.js
function curry$ (line 118) | function curry$(f, bound){
FILE: lib/Obj.js
function curry$ (line 142) | function curry$(f, bound){
FILE: lib/Str.js
function curry$ (line 80) | function curry$(f, bound){
FILE: lib/index.js
function curry$ (line 166) | function curry$(f, bound){
Condensed preview — 30 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (141K chars).
[
{
"path": ".gitignore",
"chars": 28,
"preview": "*.swp\nnode_modules\ncoverage\n"
},
{
"path": ".travis.yml",
"chars": 34,
"preview": "language: node_js\nnode_js:\n - 12\n"
},
{
"path": "CHANGELOG.md",
"chars": 4123,
"preview": "# 1.2.1\n- fix version\n\n# 1.2.0\n- add `List.remove`\n- build with LiveScript 1.6.0\n- update dependencies\n- remove coverage"
},
{
"path": "LICENSE",
"chars": 1054,
"preview": "Copyright (c) George Zahariev\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this soft"
},
{
"path": "Makefile",
"chars": 1102,
"preview": "default: all\n\nSRC = $(shell find src -name \"*.ls\" -type f | sort)\nLIB = $(SRC:src/%.ls=lib/%.js)\nLS = node_modules/lives"
},
{
"path": "README.md",
"chars": 613,
"preview": "# prelude.ls [](https://travis-ci.org/gkz/prelude"
},
{
"path": "browser/prelude-browser-min.js",
"chars": 16675,
"preview": "// Generated by LiveScript 1.6.0\n// prelude.ls 1.2.1\n// Copyright (c) George Zahariev\n// Released under the MIT License\n"
},
{
"path": "browser/prelude-browser.js",
"chars": 30911,
"preview": "// Generated by LiveScript 1.6.0\n\n// prelude.ls 1.2.1\n// Copyright (c) George Zahariev\n// Released under the MIT License"
},
{
"path": "lib/Func.js",
"chars": 1654,
"preview": "// Generated by LiveScript 1.6.0\nvar apply, curry, flip, fix, over, memoize, toString$ = {}.toString;\napply = curry$(fun"
},
{
"path": "lib/List.js",
"chars": 15544,
"preview": "// Generated by LiveScript 1.6.0\nvar each, map, compact, filter, reject, remove, partition, find, head, first, tail, las"
},
{
"path": "lib/Num.js",
"chars": 2469,
"preview": "// Generated by LiveScript 1.6.0\nvar max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, "
},
{
"path": "lib/Obj.js",
"chars": 3201,
"preview": "// Generated by LiveScript 1.6.0\nvar values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, com"
},
{
"path": "lib/Str.js",
"chars": 2104,
"preview": "// Generated by LiveScript 1.6.0\nvar split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capit"
},
{
"path": "lib/index.js",
"chars": 4932,
"preview": "// Generated by LiveScript 1.6.0\nvar Func, List, Obj, Str, Num, id, isType, replicate, prelude, toString$ = {}.toString;"
},
{
"path": "package.json",
"chars": 1048,
"preview": "{\n \"name\": \"prelude-ls\",\n \"version\": \"1.2.1\",\n \"author\": \"George Zahariev <z@georgezahariev.com>\",\n \"description\": \""
},
{
"path": "package.json.ls",
"chars": 867,
"preview": "name: 'prelude-ls'\nversion: '1.2.1'\n\nauthor: 'George Zahariev <z@georgezahariev.com>'\n\ndescription: \"prelude.ls is a fun"
},
{
"path": "preroll.ls",
"chars": 297,
"preview": "version = require './lib' .VERSION\n{VERSION: ls-version} = require 'livescript'\nconsole.log \"\"\"\n// Generated by LiveScri"
},
{
"path": "src/Func.ls",
"chars": 501,
"preview": "apply = (f, list) -->\n f.apply null, list\n\ncurry = (f) ->\n curry$ f # using util method curry$ from livescript\n\nflip ="
},
{
"path": "src/List.ls",
"chars": 5949,
"preview": "each = (f, xs) -->\n for x in xs\n f x\n xs\n\nmap = (f, xs) -->\n [f x for x in xs]\n\ncompact = (xs) -->\n [x for x in x"
},
{
"path": "src/Num.ls",
"chars": 1008,
"preview": "max = (>?)\n\nmin = (<?)\n\nnegate = (x) -> -x\n\nabs = Math.abs\n\nsignum = (x) ->\n if x < 0\n -1\n else if x > 0\n 1\n el"
},
{
"path": "src/Obj.ls",
"chars": 1178,
"preview": "values = (object) ->\n [x for , x of object]\n\nkeys = (object) ->\n [x for x of object]\n\npairs-to-obj= (object) ->\n {[x."
},
{
"path": "src/Str.ls",
"chars": 1040,
"preview": "split = (sep, str) -->\n str.split sep\n\njoin = (sep, xs) -->\n xs.join sep\n\nlines = (str) ->\n return [] unless str.leng"
},
{
"path": "src/index.ls",
"chars": 1570,
"preview": "require! [\n './Func.js'\n './List.js'\n './Obj.js'\n './Str.js'\n './Num.js'\n]\n\nid = (x) -> x\n\nis-type = (type, x) --> "
},
{
"path": "test/Func.ls",
"chars": 1608,
"preview": "require! \\sinon\n{apply, curry, flip, fix, over, memoize} = require '..' .Func\n{strict-equal: eq, not-strict-equal: not-e"
},
{
"path": "test/List.ls",
"chars": 20562,
"preview": "{\n id\n Num: {even, odd, floor, is-it-NaN}\n List: {\n each, map, filter, compact, reject, remove, partition, find,\n "
},
{
"path": "test/Num.ls",
"chars": 3952,
"preview": "{\n max, min, negate, abs, signum, quot, rem, div, mod, recip,\n pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin,"
},
{
"path": "test/Obj.ls",
"chars": 3482,
"preview": "{\n id\n Obj: {\n values, keys,\n pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists,\n empty, each, map, filt"
},
{
"path": "test/Str.ls",
"chars": 5354,
"preview": "{\n id\n Str: {\n split, join, lines, unlines, words, unwords, chars, unchars, empty, reverse\n repeat, capitalize, "
},
{
"path": "test/browser.html",
"chars": 131,
"preview": "<!doctype html>\n<script src=\"../browser/prelude-browser.js\"></script>\n<script>\n window.prelude = require('prelude-ls');"
},
{
"path": "test/index.ls",
"chars": 1089,
"preview": "{id, is-type, replicate, VERSION} = require '..'\n{strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert'\n\nsuite '"
}
]
About this extraction
This page contains the full source code of the gkz/prelude-ls GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 30 files (130.9 KB), approximately 47.3k tokens, and a symbol index with 32 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.