Humble numbers: Difference between revisions
Content added Content deleted
(→{{header|JavaScript}}: updated primitives) |
|||
Line 1,959: | Line 1,959: | ||
) : v; |
) : v; |
||
}; |
}; |
||
// justifyRight :: Int -> Char -> String -> String |
// justifyRight :: Int -> Char -> String -> String |
||
Line 1,968: | Line 1,969: | ||
) : s; |
) : s; |
||
⚫ | |||
⚫ | |||
⚫ | |||
// length :: [a] -> Int |
// length :: [a] -> Int |
||
const length = xs => |
const length = xs => |
||
⚫ | |||
⚫ | |||
⚫ | |||
(Array.isArray(xs) || 'string' === typeof xs) ? ( |
(Array.isArray(xs) || 'string' === typeof xs) ? ( |
||
xs.length |
xs.length |
||
Line 1,994: | Line 1,995: | ||
// (The image of xs under f). |
// (The image of xs under f). |
||
xs => [...xs].map(f); |
xs => [...xs].map(f); |
||
// str :: a -> String |
// str :: a -> String |
||
const str = x => |
const str = x => |
||
x.toString(); |
|||
// take :: Int -> [a] -> [a] |
// take :: Int -> [a] -> [a] |
||
Line 2,009: | Line 2,013: | ||
return x.done ? [] : [x.value]; |
return x.done ? [] : [x.value]; |
||
})); |
})); |
||
// takeWhileGen :: (a -> Bool) -> Gen [a] -> [a] |
// takeWhileGen :: (a -> Bool) -> Gen [a] -> [a] |
||
Line 2,023: | Line 2,028: | ||
return ys; |
return ys; |
||
}; |
}; |
||
// zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] |
// zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] |