Word wheel: Difference between revisions

459 bytes removed ,  2 years ago
m
m (→‎{{header|JavaScript}}: Updated primitives, tidied.)
Line 1,608:
 
return lexemes.filter(w => {
const cs = chars([...w)];
 
return 2 < cs.length && cs.every(
c => wSet.has(c)
) && elemcs.some(x => mid)(cs === x) && (
wheelFit(wheel, cs)
);
Line 1,637:
// main :: IO ()
const main = () =>
console.loggridWords(unlines["NDE", "OKG", "ELW"])(
gridWordslines(readFile(["NDEunixdict.txt", "OKG", "ELW"])()
));
lines(readFile("unixdict.txt"))
.join("\n");
));
 
 
// ---------------- GENERIC FUNCTIONS ----------------
 
// chars :: String -> [Char]
const chars = s => [...s];
 
 
// elem :: Eq a => a -> [a] -> Bool
const elem = x =>
// True if xs contains an instance of x.
xs => xs.some(y => x === y);
 
 
// lines :: String -> [String]
Line 1,688 ⟶ 1,677:
// sort :: Ord a => [a] -> [a]
const sort = xs =>
Array.from(xs).slicesort();
.sort();
 
 
Line 1,697 ⟶ 1,685:
s.toLocaleLowerCase();
 
 
// unlines :: [String] -> String
const unlines = xs =>
// A single string formed by the intercalation
// of a list of strings with the newline character.
xs.join("\n");
 
// MAIN ---
9,655

edits