lua-users home
lua-l archive

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

On Thu, Jun 7, 2012 at 12:13 PM, joao lobato <> wrote:
> FWIW, my experience with maps and filters and folds is that you don't
> really want them.

I do like a table-generating map (in its two forms) because it reduces
the extra boiler plate, but sure I know that it isn't always the most
efficient way of doing things. The ideal notation is a list
comprehension, but Lua does not go for that kind of fancy sugar.

> There are too many alternatives. Take filter: you may want to apply
> the predicate to the keys or to the values; or maybe you want
> sequencial keys in the final sequence rather than the original keys.

 When I was into macros I liked defining 'forall x in ls if f(x) do'
for filters. Of course, I had my own list comprehensions as well.

> I'm rambling now :-), but it is like Reduce in Lisp: you can
> accomplish pretty much everything with it but you must remember what
> the signature of the fold function should be

And in Haskell that's pretty much what you must _always_ do.  Purity
is a harsh mistress, and most people go for easier relationships ;)

steve d.