Solve the no connection puzzle: Difference between revisions

m
→‎JS ES6: (updated enumFromTo primitive)
m (→‎JS ES6: ( tidying ))
m (→‎JS ES6: (updated enumFromTo primitive))
Line 965:
// enumFromTo :: Enum a => a -> a -> [a]
const enumFromTo = (m, n) => {
const [tm, tn] = [typeof m, typeof n];
if (tm codePoint = s ==> tns.codePointAt(0) {,
const[tm, blnStn] = (tm[typeof ===m, 'string'),typeof n];
return tm !== tn ? undefined : base = blnS ? m.codePointAt(0() :=> m,{
end = blnS ? n.codePointAt(0) : n;const
blnS = (tm === 'string'),
 
[base, end] = [m, n].map(blnS ? codePoint : id);
return Array.from({
length: Math.floor(end - base) + 1
}, (_, i) => blnS ? String.fromCodePoint(base + i) : m + i);
} else return undefined)();
};
 
// codePoint :: String -> Int
const codePoint = s => s.codePointAt(0);
 
// id :: a -> a
const id = x => x;
 
// justifyRight :: Int -> Char -> Text -> Text
9,658

edits