UnThreaded | Threaded | Whole Thread (9) | Ignore Thread Prev | Next
Author: Kazim Big gold star, 5000 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: of 25060  
Subject: Re: Suggestion Date: 3/2/2001 11:05 AM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 1
I loved those 'goto' loops! And I was good at it, too.

I once taught a computer programming class for several months with a few different groups of students. When I was introducing the subject of loops, I always opened with this story.

There is something called a Sphex wasp. The Sphex has an interesting routine it goes through when feeding its young. It will drag some food (a caterpillar, for instance) back to its nest, go inside and check on its babies, then come out and pull the caterpillar in.

This appears to be very intelligent, motherly behavior. But researchers found something interesting. If, while the Sphex is checking on the babies, you move the caterpillar away from the nest, then when it comes out it will get confused. After it finds where the caterpillar went, it will drag it back to the nest, go inside and check on the babies again, and come back out again. While it's inside, you can drag the caterpillar away yet again, and the whole thing will be repeated. The Sphex never catches on -- it always repeats all the steps including the check, forever. So it appears that the wasp is not demonstrating intelligence or learned behavior; its brain is somehow hard-wired to perform those actions.

The moral of this story is: you should always make sure that your loops are guaranteed to reach a terminating condition, or your computer will get stuck, just like a Sphex wasp.
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Print the post  
UnThreaded | Threaded | Whole Thread (9) | Ignore Thread Prev | Next

Announcements

Pencils of Promise - Back to School Drive
"Pencils of Promise works with communities across the globe to build schools and create programs that provide education opportunities for children."
Post of the Day:
Berkshire Hathaway

IBM: Is Buffett Wrong, or Brilliant?
What was Your Dumbest Investment?
Share it with us -- and learn from others' stories of flubs.
When Life Gives You Lemons
We all have had hardships and made poor decisions. The important thing is how we respond and grow. Read the story of a Fool who started from nothing, and looks to gain everything.
Community Home
Speak Your Mind, Start Your Blog, Rate Your Stocks

Community Team Fools - who are those TMF's?
Contact Us
Contact Customer Service and other Fool departments here.
Work for Fools?
Winner of the Washingtonian great places to work, and "#1 Media Company to Work For" (BusinessInsider 2011)! Have access to all of TMF's online and email products for FREE, and be paid for your contributions to TMF! Click the link and start your Fool career.
Advertisement