mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
10 lines
331 B
Haskell
10 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)
|