Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,5 @@
function isPalindrome(str) {
return str === str.split("").reverse().join("");
}
console.log(isPalindrome("ingirumimusnocteetconsumimurigni"));

View file

@ -0,0 +1 @@
var isPal = str => str === str.split("").reverse().join("");

View file

@ -0,0 +1,33 @@
(() => {
// isPalindrome :: String -> Bool
const isPalindrome = s => {
const cs = filter(c => ' ' !== c, s.toLocaleLowerCase());
return cs.join('') === reverse(cs).join('');
};
// TEST -----------------------------------------------
const main = () =>
isPalindrome(
'In girum imus nocte et consumimur igni'
)
// GENERIC FUNCTIONS ----------------------------------
// filter :: (a -> Bool) -> [a] -> [a]
const filter = (f, xs) => (
'string' !== typeof xs ? (
xs
) : xs.split('')
).filter(f);
// reverse :: [a] -> [a]
const reverse = xs =>
'string' !== typeof xs ? (
xs.slice(0).reverse()
) : xs.split('').reverse().join('');
// MAIN ---
return main();
})();