Utility library for functional programming in Lua
Branch: master
Clone or download
Yonaba Fixed powerset (Fixes #64)
Updated powerset spec
Fixed spec
Latest commit e1fbe12 Jan 29, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Fixed docs links (Fixes #59) Sep 20, 2018
rockspec Added 2.1.0 rockspec Sep 12, 2018
spec Fixed powerset (Fixes #64) Jan 29, 2019
.gitignore Removed Telescope, added Busted, cleanup Aug 23, 2018
.luacov Updates and fixes Aug 23, 2018
.travis.yml Changed Telescope to busted Aug 22, 2018
CHANGELOG.md Updated CHANGELOG Sep 12, 2018
LICENSE Updated LICENSE Aug 22, 2018
README.md Fixed README Sep 12, 2018
moses.lua Fixed powerset (Fixes #64) Jan 29, 2019
moses_min.lua Fixed powerset (Fixes #64) Jan 29, 2019


Build Status Latest Stable License Lua

A Lua utility-belt library for functional programming.


How can I get the sum of all integers between 1 and 100 ?

local sum = M.sum(M.range(100))
print(sum) -- 5050

Say I am looking for the length of the longest word in some array ?

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 ?

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 :

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 :

local fibsum = M(M.range(25)):map(fib):sum():value()
print(fibsum) -- 196417

Feel free to download and try it on your own!




git clone git://github.com/Yonaba/Moses.git


luarocks install moses


moonrocks install moses


local M = require "moses"

Note: the full source moses.lua is quite heavy (~92 kiB, 3115 LOC). You can alternatively use the minified version (~35 kiB, 561 LOC).


Find a complete set of code examples in tutorial.md.


Credits and Acknowledgement


Run spec tests from Lua using busted with the following command from the root folder:



This work is under MIT-LICENSE
Copyright (c) 2012-2018 Roland Yonaba.