Luafun, also known as the Lua Functional Library, takes advantage of the
features of LuaJIT to help users create complex functions. Inside the module are
“sequence processors” such as
zip – they
take a user-written function as an argument and run it against every element in
a sequence, which can be faster or more convenient than a user-written loop.
Inside the module are “generators” such as
rands – they return a bounded or boundless series of values. Within the
module are “reducers”, “filters”, “composers” … or, in short, all the
important features found in languages like Standard ML, Haskell, or Erlang.
The full documentation is On the luafun section of github. However, the first
chapter can be skipped because installation is already done, it’s inside
Tarantool. All that is needed is the usual
require request. After that,
all the operations described in the Lua fun manual will work, provided they are
preceded by the name returned by the
require request. For example:
tarantool> fun = require('fun') --- ... tarantool> for _k, a in fun.range(3) do > print(a) > end 1 2 3 --- ...