DEV Community

Discussion on: Daily Challenge #194 - Spread Number

Collapse
 
craigmc08 profile image
Craig McIlwrath

Haskell, many ways

spreadNumber n = [1..n]
spreadNumber = enumFromTo 1
spreadNumber = flip take [1..]

-- The most flexible way
spreadEnum :: Enum a => a -> a
spreadEnum = enumFromTo $ toEnum 1
Collapse
 
craigmc08 profile image
Craig McIlwrath

This challenge was simple, so here's a brainfuck solution too. Only works with characters 1-9 as inputs (I have an idea for reading multidigit numbers as input, but I'm on my phone and don't want to type it out).

,>++++++[-<-------->>++++++++<]<[->>+.<<]