Created
February 10, 2016 05:58
-
-
Save hankyates/bde3f79df1574aef7d58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pure message maker | |
var messageMakerCurried = R.curry(function(parens, concat, singleMsg = {}) { | |
var {name, message, date} = singleMsg; | |
var nameTag = concat(name, ': '); | |
var dateTag = parens(date); | |
return concat( | |
concat(nameTag, message), | |
concat(' ', dateTag) | |
); | |
}); | |
function concatDef(src = '', tgt = ''){ | |
return src + tgt; | |
} | |
var wrap = (left, body, right) => concat(concat(left, body), right); | |
var parensDef = (b) => wrap('(', b, ')'); | |
var messageMaker = messageMakerCurried(parensDef, concatDef); | |
// Now messageMaker only needs singleMsg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment