3 ms·
Small steps. Just using some simple functional constructs like `map` and `filter` will do wonders for your code. You don't have to start writing everything in a
by sluukkonen 13y ago
Small steps. Just using some simple functional constructs like `map` and `filter` will do wonders for your code. You don't have to start writing everything in a purely functional manner to benefit from it.
- crazygringo 13y agoOh, for sure -- I use map/filter/reduce/etc. whenever I can when they result in cleaner/shorter code. They're great. I'm asking more about things like tail-call recursion/trampolining, function decoration -- making the "architecture" of your program more functional, rather than just a few lines here or there.
- cgag 13y agoRecursion isn't really hard once you get used to it, and often leads to shorter/cleaner code. Map/filter/reduce are themselves very clearly expressed using recursion.
- mpyne 13y agoIndeed, I've started using many functional concepts in a Perl program I maintain. Functional code isn't just good for concurrency, it also helps when trying to reason about lists and associative containers at a higher level.
- daxelrod 13y agoFor anyone interested in applying functional concepts to Perl, I highly recommend Mark Jason Dominus's Higher Order Perl[1], the full text of which is now available online for free. It starts by teaching a reader moderately familiar with Perl functional concepts, and then it deep dives into these concepts and iteratively applies them to example programs to make them better. [1]http://hop.perl.plover.com/ http://hop.perl.plover.com/