On Github cmstead / functionaljs-presentation
C, Java, PHP, Python or Ruby
Clojure, F#, Haskell, Lisp or MLvar myDataSet = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], evens, odds; evens = _(myDataSet) .filter(function(value){ return value % 2 === 0; }) odds = _(myDataSet) .filter(function(value){ return value % 2 === 1; })
var myDataSet = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], filterEvens = j.partial(j.filter, j.isEven), filterOdds = j.partial(j.filter, j.compose(j.not, j.isEven)), evens = filterEvens(myDataSet), odds = filterOdds(myDataSet);
This is a cute way to introduce some fun toys, but we can make this better. Let's simplify.
var myDataSet = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], evens = j.filter(j.isEven, myDataSet), odds = j.filter(j.isOdd, myDataSet);
var myArray = [1, 2, 3]; for(var i = 0; i < myArray.length; i++){ myArray[i] = myArray[i] * 3; }
var multiplyBy3 = j.partial(j.multiply, 3), myArray = j.map(multiplyBy3, [1, 2, 3]);
var finalValue = (passedValue !== undefined && passedValue !== null) ? defaultValue : transformation(sanitizedValue);
var sanitizedValue = j.maybe(defaultValue, transformation, passedValue);
//Stateful data management myObj.prototype = { processObj: function(tempObj){ this.finalObj.keyname = tempObj.keyName; } };
//Stateless data management function processObj(tempObj){ j.pluck('keyName', tempObj); }