munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.42k stars 1.01k forks source link

Many of my students gave the wrong answer to exercise 15.1, because + is commutative #1130

Open hugomg opened 1 year ago

hugomg commented 1 year ago

I gave the exercises in Chapter 15 to my students and several of them presented solutions that computed 2*3 + 1 instead of 1 + 2*3. They kept the structure of the first exercise, but moved the numbers around.

1 * 2 + 3
1 + 2 * 3

Perhaps this could be avoided if the exercises asked for - instead of +?

1 * 2 - 3
1 - 2 * 3