Re:Swift and the Legacy of Functional Programming
by donut2d on Monday November 21, 2016 @12:42PM
(#13007260)
I used to find the first example more difficult to read until I learned Haskell. Now I find it much more explicit about what's happening.
In the first example, because I know what "map" means, I know that `Person.init` is applied to each name. And then I know that only the valid `Person`s are returned by the `filter` call.
In the second example, I have to understanding the unique logic of the loop block to get to the same conclusion.
In the first example, because I know what "map" means, I know that `Person.init` is applied to each name. And then I know that only the valid `Person`s are returned by the `filter` call.
In the second example, I have to understanding the unique logic of the loop block to get to the same conclusion.