[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: map/grep in Lua: Shedding My Functional Perlisms
- From: Veli-Pekka Tätilä <vtatila@...>
- Date: Mon, 11 Aug 2008 17:58:31 +0300
Ben Kelly wrote:
I've taken a quick glance at both metalua and luasub before, and while
greastly powerful both do have a learning curve. I would probably get into
them if I needed major syntax mods, but this is only a small annoyance at
If using alpha compilers gives you the heebie jeebies,
you can also do
something like this:
return assert(loadstring("return function("..args..")"
.." return "..exp.." end"))()
Ah that's great, I like this solution in that it will run almost anywhere.
I'm using Lua plus and cannot in genral add other modules in it, as I'm
scripting a screen reader program at work. This solution reminds me of how
you need to eval the tr operator in Perl to get it to eval lists known at
runtime. Both evaluate code Perl to get around built-in limits, Lua here to
make the syntax a whole lot nicer.
And a simple map that inverts the truth value of each element:
map(L "e" "not e", list)
Thanks for posting this trick.
BTW, I won't be here to anser threads for a few days.
With kind regards Veli-Pekka Tätilä
Accessibility, Apps and Coding plus Synths and Music: