My wife asked me: Buy sausages, if you’ll find eggs, buy 10. What happens next?
Option #1:
if eggs >= 10 then buy(sausages, eggs=10);
Option #2:
if sausages > 0 then buy(sausages);
if eggs >= 10 then buy(eggs, 10);
Option #3
buy(sausages);
if eggs >= 10 then buy(eggs, 10);
The 3rd option is dangerous one because it could end up with never-ending run in the city looking for sausages, never buying eggs and never coming back home.
…and more. Why?
Asking me to make shopping, my wife did not stick to the principles of valid inference and correct reasoning. That’s the reason why not everybody can be a programmer :-)
buy(sausages,2); // sausages is plural, need to buy 2 otherwise its a sausage
if eggs then buy(sausages,8); // if you find eggs, you better come home with 10 sausages!
P.S. Sum of five + ten = fifteen, not 15.
FYI: Your comments don’t allow Pythonic code blocks. Indentation is stripped.
Paul,
This is an interesting insight that could be tweaked to
if eggs buy(sausages) && buy(beer, 10);Eric,
Hehe, isn’t it too radical? By the way, my wife does not mind whether I have some beer, so assuming the execution does not fall into divorce case, I’d replace 12 eggs with 10, 1 flower – let’s leave as is, and add 2 beers. Yes. looks good now :-)
I think the problem also shows that not all people can do the shopping too ;-) hehe
Tyler,
This is the very truth :-)
Mateusz,
Me thinks you’ve been staring at a screen too long. Its all about context. That’s what separates humans from computers. Hmm I wonder if that’s what separates real people from geeks too. :)