Hi. I need help with a exercise (again haha). So, I have a program that I need to do this: 1 - you start the program selecting the row that you want to use ( Example: sum 1) -- Means that we selected the 1st row to work with 2 - after that, every string that you enter will be calculated to sum (Example: 0 2) 3 - Since we selected 1 on the first part, it will output 2, and if we repeat the second like, it will output 4. Example: ``` > sum 1 > 0 1 < 1.0 > 0 2 < 3.0 > 0 5 < 8.0 ``` 4 - Now, the part where I'm stuck is that I need to implement a groupBy function, that does this: ``` > sum 1 groupby 2 > 0 100 3 < 100.0 > 0 20 3 < 120.0 > 0 40 3 < 160.0 > 0 2 25 < 2.0 > 0 7 25 < 9.0 > 10 10 3 < 170.0 ``` As you can see, it groups by the 2nd row now, if the 2nd row value changes, the value needs to change, but it needs to keep state, as you can see on the last operation, the value returns to 3 so it gets the state from the last operation with the 3 The main issue is that it needs to be chained, for example: ``` > average 1 groupby 2 groupby 3 > 0 4 1 4 < 4.0 > 1 12 1 4 < 8.0 > 2 8 1 4 < 8.0 > 3 54 2 4 < 54.0 > 4 1 2 2 < 1.0 > 5 7 2 2 < 4.0 > 6 0 2 4 < 27.0 > 7 32 2 2 < 13.333333 ``` This means I need to be able to use different groupby and keep state to every one of them, to each value. I'm really not sure how to do this, I'm willing to pay for the solution. THanks in advance. This is the code that I have at the moment: ``` getMetric :: IO () getMetric = do command <- getLine when ((words command)!!0 == "sum") $ workSum [] 0 (read ((words command)!!1)) workSum :: Int -> Int -> IO() workSum a x = do command <- getLine if command == "exit" then return () else do putStrLn (show (a + read (words(command)!!x))) workSum (a + read (words(command)!!x)) x ````