Ludic numbers: Difference between revisions

Content added Content deleted
m (Update output)
m (→‎{{header|Haskell}}: concat . map -> concatMap, (and dropped a couple of redundant $))
Line 1,467: Line 1,467:


ludic :: [Integer]
ludic :: [Integer]
ludic = 1 : unfoldr (\xs@(x:_) -> Just (x, dropEvery x xs)) [2..] where
ludic = 1 : unfoldr (\xs@(x:_) -> Just (x, dropEvery x xs)) [2 ..]
where
dropEvery n = concat . map tail . unfoldr (Just . genericSplitAt n)
dropEvery n = concatMap tail . unfoldr (Just . genericSplitAt n)


main :: IO ()
main :: IO ()
main = do
main = do
print $ take 25 $ ludic
print $ take 25 ludic
print $ length $ takeWhile (<= 1000) $ ludic
(print . length) $ takeWhile (<= 1000) ludic
print $ take 6 $ drop 1999 $ ludic
print $ take 6 $ drop 1999 ludic
-- haven't done triplets task yet</lang>
-- haven't done triplets task yet</lang>
{{out}}
{{out}}
<pre>
<pre>