Gapful numbers: Difference between revisions

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

edits