|
|
|
|
|
by rzwitserloot
2015 days ago
|
|
Most languages have something like: for (ElemType x : collection) {
# use x here
}
or: for (elem : collection) {
// use here
}
for dynamic languages or statically typed ones with lots of inferenceNot sure what you can do with this that: collections.each(x -> {
// use here
})
can't. |
|
Either way, like most things in functional programming, it's often about restricting your functions so that they're easier to reason about. There's nothing special about the map function really in any pragmatic sense except when used in conjunction with the other features a good language affords.
I'm also curious if you think something like:
is easier to understand at a quick glance than a rough equivalent using those loops above: knowing that << is the composition function.