Entries Tagged as 'programming'

Pseudo-code of An Orange Cat

//CAT V0.1
while($human-is-present){
  if(scan-for-tasty-bugs()=="none in reach"){
    perform-cat-show();
  }
}else{
  eat-bug();
}

== Update: 01/26/2009 ==
A conscientious programmer friend, who, surprisingly, wouldn’t know a historical Star Trek reference if it flew into the room and smacked him in the forehead, has helpfully notified me that the above code contains an error. The else tag cannot be applied to a while() loop.

This may explain the constant errors, spontaneous reboots, and otherwise erratic behavior displayed by the V0.1 orange cat. I have corrected the code, which turned out to be a slight mixup with some curly-braces. Perfect example of, “It compiled, so it should work.”
(Thanks, Daiv. And Piccard was clearly the better Captain.)

//CAT V0.2
while($human-is-present){
  if(scan-for-tasty-bugs()=="none in reach"){
    perform-cat-show();
  }else{
    eat-bug();
  }
}