WARNING: KOAN SPOILER ALERT
This isn’t the original version of this post. There was a first draft which banged on about the impenetrable math-lingo which Scala is steeped in. But that was before I researched and wrote Higher Order Functions <gulp/>. That helped a lot. It felt as if it gave me a toe-hold on the Functional cliff-face. The one hiding just behind the basic syntax. The one which still looms above me.
Now I’m of a much more positive frame of mind. Lets start with reduce.
Now I’m beginning to get over my fear of ‘_’, this was something I could understand. I wasn’t sure from the Koan code alone initially what this function did, but after a bit of guess-work I got it to work. Again I think I need to come up with a memorable image to associate with this to make it really persist "up there”, but in the meantime I can appreciate how powerful this could be. I’ll post on my background reading on reduce and foldLeft (and map) later.
Moving on to foldLeft:
This time I could guess pretty easily. Nice. Still no mental image springs to mind, but I’m patient.
But what’s this about “currying”? Patience. We’ll get there.