###### Example9.1.10

A candy machine is a physical “black box.” You push a button and the candy bar you desired pops out. In this case, the inputs are all of the buttons that you can press to select a candy bar, and the outputs are all of the candy bars themselves. The mechanics and electronics that connect the buttons with the candies represent the function.

Going in a little further, if the button \(A1\) delivers a bag of M&M's, then you would be surprised if you pressed \(A1\) and got anything other than M&M's. In this case, the machine wouldn't be functioning and you would get upset at your prediction ability being taken away.

Last, you might wonder if this candy machine was a function even if it was operating perfectly: if \(A1\) and \(B3\) both delivered M&M's, would that violate the definition a function?

No, the candy machine is still a function even if two buttons generate the same output candy. Remember that to be a function, each input must generate a single output; that output doesn't have to be unique for each input. So as long as each button generates a single candy each time you press it, there can be two buttons that deliver the same candy.

in-context