3 ms·
While I think the whole pattern matching + recursion thing is important to understand, once it's understood, I think it's usually better to move on to combinato
by acjohnson55 12y ago
While I think the whole pattern matching + recursion thing is important to understand, once it's understood, I think it's usually better to move on to combinators like fold/reduce/map/flatmap and such. Plus Javascript still lacks the ability to branch on a pattern match.
- JadeNB 12y ago> While I think the whole pattern matching + recursion thing is important to understand, once it's understood, I think it's usually better to move on to combinators like fold Of course, `fold` is just another language for expressing pattern-matching and well founded recursion, right? (Maybe I've got my theory mixed up, but do notice that I snuck the word "well founded" in there.) Then, of course, the other combinators that you mention (`reduce` / `map` / `flatmap`) are all just folds. On the other hand, this shouldn't be taken as a refutation of your argument; recognising and making prettier / more lightweight / even just more visible a common pattern is valuable, even if it does not, strictly speaking, increase computational power.
- acjohnson55 12y agoYep, going from arbitrary recursion to `fold` to `reduce` to `flatMap` to `map`, you're actually discarding power and expressiveness. But the good news is that you're exchanging raw expressiveness for a tool that fits the job at hand more precisely.
- eric_bullington 12y agoI agree that they're not terribly practical ways to program (I wouldn't use them in production). Still fun to play with.