Humble numbers: Difference between revisions

m
(→‎{{header|JavaScript}}: updated primitives)
Line 1,959:
) : v;
};
 
 
// justifyRight :: Int -> Char -> String -> String
Line 1,968 ⟶ 1,969:
) : s;
 
// Returns Infinity over objects without finite length.
// This enables zip and zipWith to choose the shorter
// argument when one is non-finite, like cycle, repeat etc
 
// length :: [a] -> Int
const length = xs =>
// Returns Infinity over objects without finite length.
// This enables zip and zipWith to choose the shorter
// argument when one is non-finite, like cycle, repeat etc
(Array.isArray(xs) || 'string' === typeof xs) ? (
xs.length
Line 1,994 ⟶ 1,995:
// (The image of xs under f).
xs => [...xs].map(f);
 
 
// str :: a -> String
const str = x => x.toString();
x.toString();
 
 
// take :: Int -> [a] -> [a]
Line 2,009 ⟶ 2,013:
return x.done ? [] : [x.value];
}));
 
 
// takeWhileGen :: (a -> Bool) -> Gen [a] -> [a]
Line 2,023 ⟶ 2,028:
return ys;
};
 
 
// zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
9,658

edits