[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: map/grep in Lua: Shedding My Functional Perlisms
- From: David Manura <dm.lua@...>
- Date: Mon, 11 Aug 2008 13:26:00 +0000 (UTC)
Veli-Pekka Tätilä writes:
> Does anyone use short anonymous functions with Lua ports of higher-order
> stuff like map, grep (filter), reduce, zip and the rest of the lot?
There's some things like that in these places:
http://luaforge.net/projects/stdlib/
http://metalua.luaforge.net/manual005.html#toc11
http://lua-users.org/wiki/SplitJoin
> The problem to me is the syntax. A map doing nothing looks lie:
> map(function(e) return e end, list)
> Quite a lot of typing...compared to just (Perl):
> map $_, @list;
This is discussed in
http://lua-users.org/wiki/ShortAnonymousFunctions
For example, to double the numbers in a list you could write
list2 = map(fn'P1 * 2', list) -- or
list2 = map([[P1 * 2]], list)