1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-19 22:16:57 +02:00
CodeWars/6kyu/make_the_deadfish_swim/solution.hs

11 lines
331 B
Haskell
Raw Normal View History

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)