Commit 34d984e5 authored by Mo Zhou's avatar Mo Zhou

Update upstream source from tag 'upstream/2.0.0'

Update to upstream version '2.0.0'
with Debian dir 95659eb61e623e4101d6304216908bf6c9604430
parents c93c5501 43838b63
*.bat
tsc*
ldoc*
telescope*
LuaMin*
LuaMinify*
*.ld
luacov*
*.exe
*.dll
test*
\ No newline at end of file
test*
bust*
\ No newline at end of file
--- Global configuration file. Copy, customize and store in your
-- project folder as '.luacov' for project specific configuration
-- @class module
-- @name luacov.defaults
return {
-- default filename to load for config options if not provided
-- only has effect in 'luacov.defaults.lua'
['configfile'] = '.luacov',
-- filename to store stats collected
['statsfile'] = 'luacov.stats.out',
-- filename to store report
['reportfile'] = 'luacov.report.out',
-- Run reporter on completion? (won't work for ticks)
runreport = true,
-- Delete stats file after reporting?
deletestats = false,
-- Patterns for files to include when reporting
-- all will be included if nothing is listed
-- (exclude overrules include, do not include
-- the .lua extension)
['include'] = {
'moses'
},
-- Patterns for files to exclude when reporting
-- all will be included if nothing is listed
-- (exclude overrules include, do not include
-- the .lua extension)
['exclude'] = {
'luacov$',
'luacov.reporter$',
'luacov.defaults$',
'luacov.runner$',
'luacov.stats$',
'luacov.tick$',
'mediator.*$',
'busted$',
'busted.*$',
'luassert.*$',
'pl.*$',
'say.*$',
'spec.*$'
},
}
language: c
language: python
sudo: false
env:
global:
- LUAROCKS=2.3.0
matrix:
- LUA=lua5.1
- LUA=lua5.2
- LUA=lua5.3
- LUA=luajit # latest stable version (2.0.4)
- LUA=luajit2.0 # current head of 2.0 branch
- LUA=luajit2.1 # current head of 2.1 branc
branches:
only:
- master
- LUA="lua=5.1"
- LUA="lua=5.2"
- LUA="lua=5.3"
- LUA="luajit=2.0"
- LUA="luajit=2.1"
before_install:
- source .travis/setenv_lua.sh
- pip install --user cpp-coveralls
- luarocks install Lua-cURL --server=https://luarocks.org/dev
- luarocks install luacov-coveralls --server=https://luarocks.org/dev
- luarocks install telescope 0.6.0 --server=http://rocks.moonscript.org
- pip install hererocks
- hererocks lua_install -r^ --$LUA
- export PATH=$PATH:$PWD/lua_install/bin # Add directory with all installed binaries to PATH
script: "tsc -f spec/*"
install:
- luarocks install busted
- luarocks install luacov
- luarocks install luacov-coveralls
script:
- busted --verbose --coverage
after_success:
- luacov-coveralls -c specs/.luacov
- luacov-coveralls --exclude $TRAVIS_BUILD_DIR/lua_install
branches:
except:
- gh-pages
notifications:
email:
......
if [ -z "${PLATFORM:-}" ]; then
PLATFORM=$TRAVIS_OS_NAME;
fi
if [ "$PLATFORM" == "osx" ]; then
PLATFORM="macosx";
fi
if [ -z "$PLATFORM" ]; then
if [ "$(uname)" == "Linux" ]; then
PLATFORM="linux";
else
PLATFORM="macosx";
fi;
fi
export PATH=${PATH}:$HOME/.lua:$HOME/.local/bin:${TRAVIS_BUILD_DIR}/install/luarocks/bin
bash .travis/setup_lua.sh
eval `$HOME/.lua/luarocks path`
#! /bin/bash
# A script for setting up environment for travis-ci testing.
# Sets up Lua and Luarocks.
# LUA must be "lua5.1", "lua5.2" or "luajit".
# luajit2.0 - master v2.0
# luajit2.1 - master v2.1
set -eufo pipefail
LUAJIT_VERSION="2.0.4"
LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION"
source .travis/platform.sh
LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua
LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks
mkdir $HOME/.lua
LUAJIT="no"
if [ "$PLATFORM" == "macosx" ]; then
if [ "$LUA" == "luajit" ]; then
LUAJIT="yes";
fi
if [ "$LUA" == "luajit2.0" ]; then
LUAJIT="yes";
fi
if [ "$LUA" == "luajit2.1" ]; then
LUAJIT="yes";
fi;
elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then
LUAJIT="yes";
fi
mkdir -p "$LUA_HOME_DIR"
if [ "$LUAJIT" == "yes" ]; then
if [ "$LUA" == "luajit" ]; then
curl --location https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz;
else
git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE;
fi
cd $LUAJIT_BASE
if [ "$LUA" == "luajit2.1" ]; then
git checkout v2.1;
# force the INSTALL_TNAME to be luajit
perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile
fi
make && make install PREFIX="$LUA_HOME_DIR"
ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit
ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua;
else
if [ "$LUA" == "lua5.1" ]; then
curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
cd lua-5.1.5;
elif [ "$LUA" == "lua5.2" ]; then
curl http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz
cd lua-5.2.4;
elif [ "$LUA" == "lua5.3" ]; then
curl http://www.lua.org/ftp/lua-5.3.2.tar.gz | tar xz
cd lua-5.3.2;
fi
# Build Lua without backwards compatibility for testing
perl -i -pe 's/-DLUA_COMPAT_(ALL|5_2)//' src/Makefile
make $PLATFORM
make INSTALL_TOP="$LUA_HOME_DIR" install;
ln -s $LUA_HOME_DIR/bin/lua $HOME/.lua/lua
ln -s $LUA_HOME_DIR/bin/luac $HOME/.lua/luac;
fi
cd $TRAVIS_BUILD_DIR
lua -v
LUAROCKS_BASE=luarocks-$LUAROCKS
curl --location http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz
cd $LUAROCKS_BASE
if [ "$LUA" == "luajit" ]; then
./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR";
elif [ "$LUA" == "luajit2.0" ]; then
./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR";
elif [ "$LUA" == "luajit2.1" ]; then
./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.1" --prefix="$LR_HOME_DIR";
else
./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR"
fi
make build && make install
ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks
cd $TRAVIS_BUILD_DIR
luarocks --version
rm -rf $LUAROCKS_BASE
if [ "$LUAJIT" == "yes" ]; then
rm -rf $LUAJIT_BASE;
elif [ "$LUA" == "lua5.1" ]; then
rm -rf lua-5.1.5;
elif [ "$LUA" == "lua5.2" ]; then
rm -rf lua-5.2.4;
elif [ "$LUA" == "lua5.3" ]; then
rm -rf lua-5.3.2;
fi
# Version history
## 2.0.0 (08/23/2018)
### Breaking changes
* library functions now accept iterators prototyped as `f(v, k, ...)` instead of `f(k, v, ...)`.
It improves the benefits of chaning and helps writting a clear functional-style code.
Library functions affected with this breaking change are :
`each`, `eachi`,`countf`, `map`, `reduceby`, `select`, `reject`, `all`, `groupBy`, `countBy`,
`selectWhile`, `dropWhile`, `findIndex`, `findLastIndex`, `chunk`.
* `reduceby` is now prototyped as `reduceby(t, f, pred, state)` instead of `reduceby(t, f, state, pred)`.
* `times` is now prototyped as `times(iter, n, ...)` instead of `times(iter, n, ...)`.
* `bindAll` was renamed to `bindall`
* `functions` no longer accept optional `sort` third arguments
* `sliding` was renamed to `overlapping`
* Improved `range` to handle negative progressions and start the count from 1.
* `memoize` no longer takes a `hash` function.
### Other changes
* Made `shift` a default library function, and `pop` its alias.
* Moved `shuffle` from table function to array functions
* Made `iterator` to accept an extra optional arg `n`
### Additions
#### Added support for operators
* Arithmetic operators : `add`, `sub`, `mul`, `div`, `mod`, `exp`, `pow` (alias to `exp`), `unm`, `neg` (alias to `unm`), `floordiv`, `intdiv`
* Relational operators : `eq`, `neq`, `lt`, `gt`, `le`, `ge`
* Logical operators : `land`, `lor`, `lnot`
* Concatenation operator : `concat`
* Length operator : `length`, `len` (alias to `length`)
#### Added functions
* Added `adjust` in table functions
* Added `xprod` in array functions
* Added `prepend` in array functions
* Added `zeros` in array functions
* Added `ones` in array functions
* Added `vector` in array functions
* Added `aperture` in array functions
* Added `sum` in array functions
* Added `product` in array functions
* Added `mean` in array functions
* Added `median` in array functions
* Added `powerset` in array functions
* Added `zipWith` in array functions
* Added `pairwise` in array functions
* Added `applySpec` in utility functions
* Added `nthArg` in utility functions
* Added `cond` in utility functions
* Added `castArray` in utility functions
* Added `unary` in utility functions
* Added `ary` in utility functions
* Added `rearg` in utility functions
* Added `unfold` in utility functions
* Added `converge` in utility functions
* Added `path` in object functions
#### Added function aliases
* Added `update` as alias to `adjust`
* Added `always` as alias to `constant`
* Added `intersperse` as alias to `interpose`
* Added `sliding` as alias to `aperture`
* Added `tabulate` as alias to `array`
* Added `matches` as alias to `isEqual`
* Added `average` as alias to `mean`
* Added `nAry` as alias to `ary`
* Added `transposeWith` as alias to `zipWith`
## 1.6.1 (04/27/17)
* Added `_.array`
......
Copyright (c) 2012-2014 Roland Yonaba
Copyright (c) 2012-2018 Roland Yonaba
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
......
[![Build Status](https://travis-ci.org/Yonaba/Moses.png)](https://travis-ci.org/Yonaba/Moses)
[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
[![Lua](https://img.shields.io/badge/Lua-5.1%2C%205.2%2C%205.3%2C%20JIT-blue.svg)]()
[![git-brag-stats](https://labs.turbo.run/git-brag?user=Yonaba&repo=Moses)](https://github.com/turbo/git-brag)
A Lua utility-belt library for [functional programming](http://en.wikipedia.org/wiki/Functional_programming).<br/>
## Examples
How can I get the sum of all integers between 1 and 100 ?
```lua
local sum = M.sum(M.range(100))
print(sum) -- 5050
````
Say I am looking for the length of the longest word in some array ?
```lua
local words = {'some','words','of','different','lengths'}
print(M.max(words, M.op.length)) -- 9 letters
````
What is the sum of all fibonacci numbers for n below or equal 25 ?
```lua
local function fib(n) return n < 2 and n or fib(n - 1) + fib(n - 2) end
local fibsum = M.sum(M.map(M.range(25), fib))
print(fibsum) -- 196417
````
Or let us do the same, opbject-oriented style with chaining :
```lua
local function fib(n) return n < 2 and n or fib(n - 1) + fib(n - 2) end
local fibsum = M.chain(M.range(25)):map(fib):sum():value()
print(fibsum) -- 196417
````
Or even shorter :
```lua
local fibsum = M(M.range(25)):map(fib):sum():value()
print(fibsum) -- 196417
````
Feel free to download and try it on your own!
## Download
### Archive
* __zip__: [1.6.1 (stable)](http://github.com/Yonaba/Moses/archive/Moses-1.6.1-1.zip) | [dev](http://github.com/Yonaba/Moses/archive/master.zip) | [all releases](http://github.com/Yonaba/Moses/tags)
* __tarball__: [1.6.1 (stable)](http://github.com/Yonaba/Moses/archive/Moses-1.6.1-1.tar.gz) | [dev](http://github.com/Yonaba/Moses/archive/master.tar.gz) | [all releases](http://github.com/Yonaba/Moses/tags)
* __2.0.0__ *(latest stable)*: [zip](http://github.com/Yonaba/Moses/archive/Moses-2.0.0-1.zip) | [tar.gz](http://github.com/Yonaba/Moses/archive/Moses-2.0.0-1.tar.gz)
* __Previous versions__ : [tags](http://github.com/Yonaba/Moses/tags)
### Bash
......@@ -18,23 +57,24 @@ git clone git://github.com/Yonaba/Moses.git
````
### LuaRocks
```
````
luarocks install moses
````
### MoonRocks
```bash
````
moonrocks install moses
````
## Usage
```lua
local _ = require "moses"
local M = require "moses"
````
*Note:* the full source [moses.lua](https://github.com/Yonaba/Moses/blob/master/moses.lua) is quite heavy (~70 kiB). You can alternatively use the [minified version](https://github.com/Yonaba/Moses/blob/master/moses_min.lua) (~22 kiB).
*Note:* the full source [moses.lua](https://github.com/Yonaba/Moses/blob/master/moses.lua) is quite heavy (~83 kiB, 2780 LOC). You can alternatively use the [minified version](https://github.com/Yonaba/Moses/blob/master/moses_min.lua) (~32 kiB, 521 LOC).
## Tutorial
......@@ -42,28 +82,28 @@ Find a complete set of code examples in [tutorial.md](https://github.com/Yonaba/
## Documentation
* See *doc* folder : [doc](https://github.com/Yonaba/Moses/blob/master/doc)
* Or browse it online : see [online doc](http://yonaba.github.io/Moses/doc).
* Read it [online](http://yonaba.github.io/Moses/doc).
## Credits and Acknowledgement
* [Jeremy Ashkenas](https://github.com/jashkenas), for the amazing [Underscore.js](http://documentcloud.github.com/underscore/)
* [Marcus Irven](http://mirven.github.com/underscore.lua/)'s and [JTArchie](https://github.com/jtarchie/underscore-lua)'s 1-to-1 ports that also inspired this
* [Marcus Irven](http://mirven.github.com/underscore.lua/)'s and [JT Archie](https://github.com/jtarchie/underscore-lua)'s 1-to-1 ports that also inspired this
* [Matthew Rocklin](https://github.com/mrocklin)'s [Toolz](https://github.com/pytoolz/toolz/) from which I borrowed some ideas
* [LDoc](https://github.com/stevedonovan/ldoc/) used to generate the current HTML documentation.
* [Steve Donovan](https://github.com/stevedonovan)'s [LDoc](https://github.com/stevedonovan/ldoc/), used to generate the current HTML documentation.
* [Mark Langen](https://github.com/stravant)'s [LuaMinify](https://github.com/stravant/LuaMinify/), used to generate a minified version of this library.
## Specification
Run [spec tests](https://github.com/Yonaba/Moses/blob/master/spec) using [Telescope](https://github.com/norman/telescope) with the following command from the root folder:
Run [spec tests](https://github.com/Yonaba/Moses/blob/master/spec) from Lua using [busted](https://github.com/Olivine-Labs/busted/) with the following command from the root folder:
````
tsc -f spec/*
busted
````
## License
This work is under [MIT-LICENSE](http://www.opensource.org/licenses/mit-license.php)<br/>
Copyright (c) 2012-2017 Roland Yonaba. <br/>
Copyright (c) 2012-2018 Roland Yonaba. <br/>
See [LICENSE](LICENSE).
This diff is collapsed.
/* BEGIN RESET
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.8.2r1
*/
html {
color: #000;
background: #FFF;
}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
margin: 0;
padding: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
fieldset,img {
border: 0;
}
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
font-style: inherit;
font-weight: inherit;
}
del,ins {
text-decoration: none;
}
li {
margin-left: 20px;
}
caption,th {
text-align: left;
}
h1,h2,h3,h4,h5,h6 {
font-size: 100%;
font-weight: bold;
}
q:before,q:after {
content: '';
}
abbr,acronym {
border: 0;
font-variant: normal;
}
sup {
vertical-align: baseline;
}
sub {
vertical-align: baseline;
}
legend {
color: #000;
}
input,button,textarea,select,optgroup,option {
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
}
input,button,textarea,select {*font-size:100%;
}
/* END RESET */
body {
margin-left: 1em;
margin-right: 1em;
font-family: arial, helvetica, geneva, sans-serif;
background-color: #ffffff; margin: 0px;
}
code, tt { font-family: monospace; font-size: 1.1em; }
span.parameter { font-family:monospace; }
span.parameter:after { content:":"; }
span.types:before { content:"("; }
span.types:after { content:")"; }
.type { font-weight: bold; font-style:italic }
body, p, td, th { font-size: .95em; line-height: 1.2em;}
p, ul { margin: 10px 0 0 0px;}
strong { font-weight: bold;}
em { font-style: italic;}
h1 {
font-size: 1.5em;
margin: 20px 0 20px 0;
}
h2, h3, h4 { margin: 15px 0 10px 0; }
h2 { font-size: 1.25em; }
h3 { font-size: 1.15em; }
h4 { font-size: 1.06em; }
a:link { font-weight: bold; color: #004080; text-decoration: none; }
a:visited { font-weight: bold; color: #006699; text-decoration: none; }
a:link:hover { text-decoration: underline; }
hr {
color:#cccccc;
background: #00007f;
height: 1px;
}
blockquote { margin-left: 3em; }
ul { list-style-type: disc; }
p.name {
font-family: "Andale Mono", monospace;
padding-top: 1em;
}
pre {
background-color: rgb(245, 245, 245);
border: 1px solid #C0C0C0; /* silver */
padding: 10px;
margin: 10px 0 10px 0;
overflow: auto;
font-family: "Andale Mono", monospace;
}
pre.example {
font-size: .85em;
}
table.index { border: 1px #00007f; }
table.index td { text-align: left; vertical-align: top; }
#container {
margin-left: 1em;
margin-right: 1em;
background-color: #f0f0f0;
}
#product {
text-align: center;
border-bottom: 1px solid #cccccc;
background-color: #ffffff;
}
#product big {
font-size: 2em;
}
#main {
background-color: #f0f0f0;
border-left: 2px solid #cccccc;
}
#navigation {
float: left;
width: 14em;
vertical-align: top;
background-color: #f0f0f0;
overflow: visible;
}
#navigation h2 {
background-color:#e7e7e7;
font-size:1.1em;
color:#000000;
text-align: left;
padding:0.2em;
border-top:1px solid #dddddd;
border-bottom:1px solid #dddddd;
}
#navigation ul
{
font-size:1em;
list-style-type: none;
margin: 1px 1px 10px 1px;
}
#navigation li {
text-indent: -1em;
display: block;
margin: 3px 0px 0px 22px;
}
#navigation li li a {
margin: 0px 3px 0px -1em;
}
#content {
margin-left: 14em;
padding: 1em;
width: 700px;
border-left: 2px solid #cccccc;
border-right: 2px solid #cccccc;
background-color: #ffffff;
}
#about {
clear: both;
padding: 5px;
border-top: 2px solid #cccccc;
background-color: #ffffff;
}
@media print {
body {
font: 12pt "Times New Roman", "TimeNR", Times, serif;
}
a { font-weight: bold; color: #004080; text-decoration: underline; }
#main {
background-color: #ffffff;
border-left: 0px;
}
#container {
margin-left: 2%;
margin-right: 2%;
background-color: #ffffff;
}
#content {
padding: 1em;
background-color: #ffffff;
}
#navigation {
display: none;
}
pre.example {
font-family: "Andale Mono", monospace;
font-size: 10pt;
page-break-inside: avoid;
}
}
table.module_list {
border-width: 1px;
border-style: solid;
border-color: #cccccc;
border-collapse: collapse;
}
table.module_list td {
border-width: 1px;
padding: 3px;
border-style: solid;
border-color: #cccccc;
}
table.module_list td.name { background-color: #f0f0f0; min-width: 200px; }
table.module_list td.summary { width: 100%; }
table.function_list {
border-width: 1px;
border-style: solid;
border-color: #cccccc;
border-collapse: collapse;
}
table.function_list td {
border-width: 1px;
padding: 3px;
border-style: solid;
border-color: #cccccc;
}
table.function_list td.name { background-color: #f0f0f0; min-width: 200px; }
table.function_list td.summary { width: 100%; }
ul.nowrap {
overflow:auto;
white-space:nowrap;
}
dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
dl.table h3, dl.function h3 {font-size: .95em;}
/* stop sublists from having initial vertical space */
ul ul { margin-top: 0px; }
ol ul { margin-top: 0px; }
ol ol { margin-top: 0px; }
ul ol { margin-top: 0px; }
/* make the target distinct; helps when we're navigating to a function */
a:target + * {
background-color: #FF9;
}
/* styles for prettification of source */
pre .comment { color: #558817; }
pre .constant { color: #a8660d; }
pre .escape { color: #844631; }
pre .keyword { color: #aa5050; font-weight: bold; }
pre .library { color: