lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

home site:

luaiter is a rewritten version of luafun[1]: a high-performance
functional programming library for Lua designed with LuaJIT's trace
compiler in mind. luaiter focus plain Lua performance improve and
follows the standard Lua iteration protocol.

Some improves:
  - avoid any memory allocation when iteration.
  - use standard iteration protocol.
  - support Lua 5.3 bit operators.
  - add more useful functions like `scan` and `flatmap`.
  - add a powerful `selector` interface for quick-and-dirty lambda
    function support.

Why re-invert wheel:
  - I know at least two library about this: luafun[1] and lua-itertools[2]
  - while lua-itertools use coroutine, too heavily for me.
  - luafun mainly optimize for LuaJIT, but I mainly use plain Lua.
  - luafun may allocate memory when iterating, but I need use it in game.
  - luafun has a custom iterator usage, can not use together with e.g. io.lines()

luaiter could be used in Unity/cocos2d-x games, and I could use it write code tools.
(I have a lot of structure data process mission, just like generate OpenGL binding, etc.)

Some example:

> -- Functional style
> print(reduce(_1+_2, 0, map(_1^2, range(100))))

> -- Object-oriented style
> print(range(100):map(_1^2):reduce(_1+_2))


Xavier Wang.