Exercise 13
The official answer is:
def simulateMachine(inputs: List[Input]): State[Machine, (Int, Int)] = for {
_ <- sequence(inputs map (modify[Machine] _ compose update))
s <- get
} yield (s.coins, s.candies)
the position of the second placeholder in the second line really confuses me, the right answer from my perspective should be this:
def simulateMachine(inputs: List[Input]): State[Machine, (Int, Int)] = for {
_ <- sequence(inputs map ((modify[Machine] compose update) _))
s <- get
} yield (s.coins, s.candies)
please help me understand why the first answer is right, thanks very much