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
return tm !== tn ? undefined :
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);
}
};
// codePoint :: String -> Int
const codePoint = s => s.codePointAt(0);
// id :: a -> a
const id = x => x;
// justifyRight :: Int -> Char -> Text -> Text
|