I’ve noticed ruby has nice high level functions.
But I cannot find the reduce or foldr method.
I’ve discovered the inject method in the Ruby book.
It is very similar to one of the fold(l/r) methods in SML.
The def of foldr is:
- denotes any kind of operator with 2 operands
e is the (right) unit element
folr e + array = array1 + (array2 + … + (arrayn + e)…)
And foldl is the other way (if + is associative, then it gives the same
If inject will be available, will foldl and foldr (=reduce) also?
Thanks in advance.
±[Kontra, Gergely @ Budapest University of Technology and Economics]-+
Email: email@example.com, firstname.lastname@example.org |