mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 19:19:07 +01:00
11 lines
331 B
Haskell
11 lines
331 B
Haskell
|
module Kata.Deadfish (parse) where
|
||
|
|
||
|
parse :: String -> [Int]
|
||
|
parse = snd . foldl exec (0, [])
|
||
|
where exec (value, output) cmd = case cmd of
|
||
|
'i' -> (value + 1, output)
|
||
|
'd' -> (value - 1, output)
|
||
|
's' -> (value * value, output)
|
||
|
'o' -> (value, output ++ [value])
|
||
|
_ -> (value, output)
|