Gapful numbers: Difference between revisions
Content added Content deleted
m (→{{header|LOLCODE}}: Fixed display of : which was messing up the sybntax highlighting) |
|||
Line 1,468: | Line 1,468: | ||
Or, defining the predicate in applicative terms, and wrapping the output: |
Or, defining the predicate in applicative terms, and wrapping the output: |
||
<lang haskell>import Data.List |
<lang haskell>import Data.List (intercalate) |
||
import Data.List ( |
import Data.List.Split (chunksOf) |
||
⚫ | |||
⚫ | |||
isGapful :: Int -> Bool |
isGapful :: Int -> Bool |
||
isGapful = |
|||
⚫ | |||
(0 ==) |
|||
. (<*>) |
|||
rem |
|||
⚫ | |||
--------------------------- TEST ------------------------- |
|||
main :: IO () |
main :: IO () |
||
main = |
main = |
||
mapM_ |
mapM_ |
||
(putStrLn . showSample) |
(putStrLn . showSample) |
||
[ "First 30 gapful numbers >= 100" |
[ "First 30 gapful numbers >= 100", |
||
"First 15 Gapful numbers >= 1000000", |
|||
"First 10 Gapful numbers >= 1000000000" |
|||
] |
] |
||
Line 1,491: | Line 1,493: | ||
showSample k = |
showSample k = |
||
let ws = words k |
let ws = words k |
||
in k <> ":\n\n" |
in k <> ":\n\n" |
||
unlines |
<> unlines |
||
(fmap (intercalate ", " . fmap show) $ |
( fmap (intercalate ", " . fmap show) $ |
||
chunksOf 5 $ |
|||
take |
|||
(read (ws !! 1)) |
|||
[read (ws !! 5) :: Int ..] |
|||
)</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre>First 30 gapful numbers >= 100: |
<pre>First 30 gapful numbers >= 100: |