Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.


A Higher Order Idea stolen from Ramda.js

Start with Paul Bennett, who is a Perl guy I know from Google Plus. He pointed to a function in Ramda.js, which allows you to create a number of filters as anonymous functions, put them in an array, pass that array, and do that test in one line.

// Instead of 

if ( x > 10 && x % 2 --- 0 ) { console.log( 'Big and Even' ) }

var gt10 = function(x) { return x > 10 }
var even = R.allPredicates( [ gt10,even ] ) ;

if ( f( x ) ) { console.log( 'Big and Even' ) }

Now, imagine if we're testing several things, rather than just one.

I thought "Hey, there's so much I could do with this in Perl. I've been thinking about writing a mail filter that takes a function Higher Order Perl style, so could generate a function based on the config file and pass it into the middle of Mail::IMAPClient so I don't have to generate a menagerie of one-trick ponies. This, of course, is a fairly big idea to work with, and the allPredicates is small enough that, with a half-hour of working through Perl I mostly thought I knew, I came up with this. Fifteen lines of code. I am happy.