Moses
所属分类:collect
开发工具:Lua
文件大小:0KB
下载次数:0
上传日期:2019-12-18 02:39:18
上 传 者:
sh-1993
说明: Lua中函数编程的实用程序库,
(Utility library for functional programming in Lua,)
文件列表:
.luacov (1231, 2019-11-09)
.travis.yml (635, 2019-11-09)
CHANGELOG.md (11684, 2019-11-09)
LICENSE (1062, 2019-11-09)
doc/ (0, 2019-11-09)
doc/index.html (163941, 2019-11-09)
doc/manual/ (0, 2019-11-09)
doc/manual/tutorial.md.html (149604, 2019-11-09)
doc/tutorial.md (58783, 2019-11-09)
moses.lua (91445, 2019-11-09)
moses_min.lua (34507, 2019-11-09)
rockspec/ (0, 2019-11-09)
rockspec/moses-1.3-0.rockspec (837, 2019-11-09)
rockspec/moses-1.3-1.rockspec (776, 2019-11-09)
rockspec/moses-1.3.1-1.rockspec (860, 2019-11-09)
rockspec/moses-1.3.2-1.rockspec (860, 2019-11-09)
rockspec/moses-1.3.2.1-1.rockspec (866, 2019-11-09)
rockspec/moses-1.4.0-1.rockspec (743, 2019-11-09)
rockspec/moses-1.5.0-1.rockspec (743, 2019-11-09)
rockspec/moses-1.5.1-1.rockspec (743, 2019-11-09)
rockspec/moses-1.6.0-1.rockspec (743, 2019-11-09)
rockspec/moses-1.6.1-1.rockspec (743, 2019-11-09)
rockspec/moses-2.0.0-1.rockspec (750, 2019-11-09)
rockspec/moses-2.1.0-1.rockspec (750, 2019-11-09)
spec/ (0, 2019-11-09)
spec/array_spec.lua (28429, 2019-11-09)
spec/chaining_spec.lua (739, 2019-11-09)
spec/func_spec.lua (22922, 2019-11-09)
spec/import_spec.lua (618, 2019-11-09)
spec/object_spec.lua (21099, 2019-11-09)
spec/op_spec.lua (4602, 2019-11-09)
spec/table_spec.lua (23826, 2019-11-09)
[![Build Status](https://travis-ci.org/Yonaba/Moses.png)](https://travis-ci.org/Yonaba/Moses)
[![Latest Stable](https://img.shields.io/badge/Latest_Stable-2.1.0-blue.svg)](https://github.com/Yonaba/Moses/releases/tag/Moses-2.1.0-1)
[![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)]()
A Lua utility-belt library for [functional programming](http://en.wikipedia.org/wiki/Functional_programming).
## 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, object-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
* __2.1.0__ *(latest stable)*: [zip](http://github.com/Yonaba/Moses/archive/Moses-2.1.0-1.zip) | [tar.gz](http://github.com/Yonaba/Moses/archive/Moses-2.1.0-1.tar.gz)
* __Previous versions__ : [tags](http://github.com/Yonaba/Moses/tags)
### Bash
```bash
git clone git://github.com/Yonaba/Moses.git
````
### LuaRocks
````
luarocks install moses
````
### MoonRocks
````
moonrocks install moses
````
## Usage
```lua
local M = require "moses"
````
*Note:* the full source [moses.lua](https://github.com/Yonaba/Moses/blob/master/moses.lua) is quite heavy (~92 kiB, 3115 LOC). You can alternatively use the [minified version](https://github.com/Yonaba/Moses/blob/master/moses_min.lua) (~35 kiB, 561 LOC).
## Tutorial
Find a complete set of code examples in [tutorial.md](https://github.com/Yonaba/Moses/blob/master/doc/tutorial.md).
## Documentation
* 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 [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
* [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) from Lua using [busted](https://github.com/Olivine-Labs/busted/) with the following command from the root folder:
````
busted
````
## License
This work is under [MIT-LICENSE](http://www.opensource.org/licenses/mit-license.php)
Copyright (c) 2012-2018 Roland Yonaba.
See [LICENSE](LICENSE).
近期下载者:
相关文件:
收藏者: