suggested library additions: lists:revmap/2, lists:revmap/3

James Hague james.hague@REDACTED
Sat Aug 26 19:43:53 CEST 2006

Like map, but returns a list in reverse order.  An optional third
parameter is appened to the end of the returned list:

revmap(F, L) -> revmap(F, L, []).
revmap(F, [H|T], Acc) -> revmap(F, T, [F(H)|Acc]);
revmap(_, [],  Acc) -> Acc.

I've found this useful in my code, and I was surprised that it's not
in the standard library.

More information about the erlang-questions mailing list