September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,21 @@
(() => {
'use strict';
// stripChars :: String -> String -> String
const stripChars = (strNeedles, strHayStack) =>
strHayStack.replace(RegExp(`[${strNeedles}]`, 'g'), '');
// GENERIC FUNCTION
// curry :: ((a, b) -> c) -> a -> b -> c
const curry = f => a => b => f(a, b);
// TEST FUNCTION
const noAEI = curry(stripChars)('aeiAEI');
// TEST
return noAEI('She was a soul stripper. She took my heart!');
// 'Sh ws soul strppr. Sh took my hrt!'
})();

View file

@ -0,0 +1,27 @@
(() => {
'use strict';
// stripChars :: String -> String -> String
const stripChars = (strNeedles, strHayStack) =>
strHayStack.split('')
.filter(x => !elem(x, strNeedles))
.join('');
// GENERIC FUNCTIONS
// elem :: Eq a => a -> [a] -> Bool
const elem = (x, xs) => xs.indexOf(x) !== -1;
// curry :: ((a, b) -> c) -> a -> b -> c
const curry = f => a => b => f(a, b);
// TEST FUNCTION
const noAEI = curry(stripChars)('aeiAEI');
// TEST
return noAEI('She was a soul stripper. She took my heart!');
// 'Sh ws soul strppr. Sh took my hrt!'
})();