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:
Or, defining the predicate in applicative terms, and wrapping the output:
<lang haskell>import Data.List
import Data.List.Split (
▲----------------------- GAPFUL NUMBERS ---------------------
isGapful :: Int -> Bool
isGapful =
isGapful = (0 ==) . (<*>) rem (read . (<*>) [head, last] . pure . show)▼
(0 ==)
. (<*>)
rem
main :: IO ()
main =
mapM_
(putStrLn . showSample)
[ "First 30 gapful numbers >= 100",
]
Line 1,491 ⟶ 1,493:
showSample k =
let ws = words k
in k <> ":\n\n"
<> unlines
( fmap (intercalate ", " . fmap show) $
take
(read (ws !! 1))
[read (ws !! 5) :: Int ..]
)</lang>
{{Out}}
<pre>First 30 gapful numbers >= 100:
|