const greet = name => "Hi " + name
const greetAndAddExclamation = (greetfn, name) =>
exclamation => greetfn(name).trimRight() + exclamation
function greetAndAddExclamation (greetfn, name) {
return function (exclamation) {
greetfn(name).trimRight() + exclamation
}
}
greetAndAddExclamation(greet, "magnus ")("!")
const greet = name => "Hi " + name
const names = ["magnus", "codenight"]
const addExclamation =
(str, exclamation) => str.trimRight() + exclamation
names.map(greet)
.map(x => addExclamation(x, "!"))
const greet = name => "Hi " + name
const addExclamation = exclamation =>
str => str.trimRight() + exclamation
const capitalize = name =>
name[0].toUpperCase() + name.substr(1)
addExclamation("!")(greet(capitalize("magnus")))
oskay @ flickr
const validLength = name => name.length <= 6
const onlyValidChars =
name => ['!', '?'].every(c => !name.includes(c))
const applyAllPar = ( ... fns ) =>
arg => fns.par.map(f => f(arg))
const validations = applyAllPar(validateLength, validateChars)
const names = new Parallel(["codenight", "magnus"])
names.filter(validations.every(Boolean))
.map(addGreetingAndExclamation)