Skip to content

davidhollander/fn

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

fn.lua

About

fn.lua provides functional programming extras for Lua and LuaJIT. Unlike some other functional libraries, it preserves ending nil values by using "select". It aims to support the manipulation of ordered data using both traditional tables and multi arity arguments, rather than creating a new array type. It will avoid implementing library functions in terms of each other to reduce the height of the call stack for end users.

Getting Started

Copy fn.lua into your lua module directory. On Ubuntu, this is /usr/local/share/lua/5.1/

importing

require'fn'

create a new function that will call Fold Left using an addition function as the first parameter

sum = fn.partial( fn.foldl, function(a, b) return a+b end)

call sum with a list of numbers

x = sum(1, 2, 3, 4, 5, 6, 7, 8, 9)
print(x)
-- 45

see fn.lua and tests.lua for additional information.

About

Functional programming library for Lua and LuaJIT with test coverage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages