1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-08 18:49:07 +01:00
CodeWars/6kyu/make_the_deadfish_swim/solution.hs
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

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)