Posts from groovy

Starting the Journey

Haskell real-world-haskell, functional, groovy

One of the greatest things that have come out of learning and working everyday in a Java like language that not just supports lambdas but makes them a way of life, is that before you know it you are getting really curious about this functional programming thing. At first my curiosity lead me to Scala, and why not, it’s been totally hyped, compiles to JVM bytecode, and has some awesome things going on. But, boy was I unprepared for all the concepts that Scala required me to understand just to read it’s standard libraries. I gave Scala the old college try but didn’t come away with much other than this burning question of “What the f* are Monads?”, and I decided I needed to learn functional concepts in a more clean room environment rather than one that merges them with the OO world.

Groovy's Inject

Java groovy, functional

When I started getting into functional programming I relaized that Groovy has some features which could be considered functional or higher-order functions. I commonly use methods like findAll (filter) and collect (map). As I was reading Beginning Scala by David Pollack I came across fold which I had never used before. Groovy calls this inject. inject allows us to walk though a data structure calling a function on each node, the result of that function is then passed to the same function being called on the next node.