Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
function stripchars(string, chars) {
return string.replace(RegExp('['+chars+']','g'), '');
}

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!'
})();