• Stars
    star
    604
  • Rank 71,495 (Top 2 %)
  • Language
    Lua
  • License
    MIT License
  • Created almost 12 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utility library for functional programming in Lua

Build Status Latest Stable License Lua

A Lua utility-belt library for functional programming.

Examples

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, object-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!

Download

Archive

Bash

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

LuaRocks

luarocks install moses

MoonRocks

moonrocks install moses

Usage

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).

Tutorial

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

Documentation

Credits and Acknowledgement

Specification

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

busted

License

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

More Repositories

1

Jumper

Fast, lightweight and easy-to-use pathfinding library for grid-based games
Lua
590
star
2

30log

30 lines library for object orientation in Lua
Lua
413
star
3

awesome-one-person-games

🎮 A curated list of successul games, made (quite) entirely by a lone gamedev.
352
star
4

delaunay

Delaunay triangulation for convex polygon
Lua
102
star
5

Lua-Class-System

Lua Class System (LCS) is a small library which offers a clean, minimalistic but powerful API for (Pseudo) Object Oriented programming style using Lua.
Lua
62
star
6

Allen

An utility library to manipulate strings in Lua
Lua
45
star
7

strictness

Tracks accesses and assignments of undefined variables in Lua
Lua
36
star
8

love2d-assets-loader

Assets Loader for Löve2D Framework
Lua
36
star
9

FloodFill

Various floodfill algorithms implementation
Lua
18
star
10

Binary-Heaps

Implementation of binary heaps data structure in pure Lua
Lua
18
star
11

guard.lua

Minimalistic library providing Elixir-style guards for Lua
Lua
16
star
12

Steering-Behaviors

Steering behaviors algorithms for autonomously moving agents and flocks implemented in Lua
Lua
15
star
13

broad-phase-algorithms

Lua Implementation of space-partitioning techniques for broad-phase collision detection
Lua
14
star
14

Jumper-Benchmark

Benchmark tests for the pathfinding library Jumper featuring 2012 GPPC map set
Lua
12
star
15

tuple.lua

Minimal implementation of ordered n-tuples class in Lua
Lua
11
star
16

Raytracer

A basic raytracer written in Lua
Lua
11
star
17

Jumper-Examples

Demos and examples of use for the pathfinding library Jumper with various Lua frameworks and game engines
11
star
18

dijkstra-map

Demo illustrating the use of dijkstra map for turn-based pathfinding for multi agents on weighted grids
Lua
10
star
19

yonaba.github.com

Personal DevBlog Pages
CSS
7
star
20

character-physics-demo

A technical demo (made with Löve2D) implementing physics-based movement and jump with various time integration methods
Lua
7
star
21

Java-samples

Collection of Java snippets implemented for learning purposes
Java
7
star
22

uplink-psp

A small clone of Uplink Hacker Elite written in Lua for PSP
Lua
6
star
23

luigi-world

An old and minimalist platformer game with Luigi written in Lua for PSP
Lua
5
star
24

PiL3

Going through the exercices of the book Programming in Lua, Third Ed.
Lua
5
star
25

30logclasscommons

Plugin for compatibility between 30log and Class-commons
Lua
4
star
26

Starz-Puzzle

A small Lua puzzle game written for the sake of LÖVE
Lua
4
star
27

SOR

Library for solving linear equation system using Successive Over Relaxation method
Lua
4
star
28

pascal-exercises

Collection of maths problems implemented in pascal programming language for learning purposes
Pascal
4
star
29

smallpt-lua

Lua
4
star
30

adventofcode

My attempt at solving AdventOfCode Problems with Lua, on my spare times
Lua
3
star
31

lua-travis-coveralls

Getting Lua 5.1, 5.2 and LuaJit 2.0 specs to work with integration with Travis-CI and Coveralls.io
Shell
3
star
32

xcorr.bas

Adds cross correlation and autocorrelation functions to Microsoft Excel
VBA
3
star
33

treap.lua

A simple treap data structure implemented in Lua
Lua
3
star
34

Win64-Installer-ArcView3.x

ISS Script to generate A Windows x64 compatible setup of ESRI's ArcView3.x
Shell
2
star
35

lua-system-shell

Small old homebrew Lua shell written in Lua for PSP
Lua
2
star
36

hokuto-no-ken

Small old homebrew Lua game written in Lua for PSP
Lua
2
star
37

danzeff-lua-keyboard

Emulating Danzeff's Keyboard for LuaPlayerHM
Lua
2
star
38

Hydraulics

VB macros to evaluate hydraulics parameters. Exposes solvers as functions to Excel API
FreeBasic
2
star
39

mario-kart

A small and minimalist Mario Kart homebrew game written in Lua for PSP
Lua
2
star
40

Excel-Pour-Reseaux-Ramifies

Macro VBA associée à un classeur Excel pour le calcul et l'analyse de réseaux hydrauliques ramifiés.
Visual Basic
2
star
41

covid19_clustering_africa

Attempt at clustering African countries using country-level variables and COVID-19 prevalence
R
1
star
42

2ie-master-thesis-csl-style

CSL Style developed for 2iE students Master thesis
1
star
43

ID-em

Create unique identifiers for each entity in a ESRI Shapefile
1
star
44

the-labyrinth

A small technical raycasting demo written in Lua for PSP
Lua
1
star
45

ET0_Analysis_Burkina_Faso

R scripts for Figures and Data Analysis Accompanying an academic paper on reference evapotranspiration analysis in Burkina Faso
R
1
star
46

sivakumar.bas

A VBA module to calculate the rainy season onset/ending dates and the count of occurences of dry spells
VBA
1
star