lua-users home
lua-l archive

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


Second, support for 'string lambdas' would be cool:

_.({1,2,3,4}):chain():map '|i| i + 1' :select '|i| i%2==0': value()

There's a slight hit to compile them, but thereafter they can be
easily memoized. They don't require any syntax enhancements so David K
can only have style objections ;)

This is an interesting idea, I'd have to either:
1) insert a 'return' so it would limit the string lambda to a single _expression_ 
2) have a complex parser
3) require the 'return' to be explicit (e.g. map '|i| return i + 1')

I'll play around with this idea, if anybody wants to submit any code I'd be happy to take a look.

Alright, here is the start of creating a function from the string part: http://gist.github.com/252114

Not dealing with the implicit return the parsing would be fairly trivial.