Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis

gdyrrahitis/pipeline.js Secret

Created Jul 10, 2019
Embed
What would you like to do?
const append = (text) => (value) => value + text;
const removeTheLetter = (letter) => (sentence) =>
sentence
.split('')
.filter(c => c !== letter)
.join('');
const makeLetterUpperCase = (letter) => (sentence) =>
sentence.split('')
.map(c => c === letter ? c.toUpperCase() : c)
.join('');
const removeWordsWithLessThanFourLetters = (sentence) =>
sentence
.split(' ')
.filter(word => word.length > 4)
.join(' ');
const phrase = 'Welcome';
const result = removeWordsWithLessThanFourLetters(
makeLetterUpperCase('e')(
makeLetterUpperCase('a')(
makeLetterUpperCase('o')(
removeTheLetter('i')(
append(' pipelining')(
append(' I hope you like')(
append(' Functional Programming')(
append(' to')(phrase)
)
)
)
)
)
)
)
);
console.log(result);
// prints: WElcOmE FunctOnAl PrOgrAmmng ppElnng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.