CAZine: issue 6, December 2009

CAZine: issue 6, December 2009

Anomalies of Code

By: Gen Zerhash

From the lack of responses, and my un-dieing will to increase the amounts of comments coming in. If you have a bit of code which doesn’t make sense to you please post in the comments. You may be featured in the following months code. If you get featured you will gain +v in irc, and an award!

This Months Challenge

  1. JAPH Souffle.
  2.  
  3. Ingredients.
  4. 44 potatoes
  5. 114 onions
  6. 101 g flour
  7. 107 kg salt
  8. 99 bottles of beer
  9. 97 cups acid
  10. 72 l oil
  11. 32 pins
  12. 8 l urine
  13. 108 pines
  14. 101 laptops
  15. 80 mouses
  16. 47 keyboards
  17. 102 idiots
  18. 104 hackers
  19. 67 voodoo puppets
  20. 116 crackpipes
  21. 111 megawatts
  22. 110 numbers
  23. 97 commas
  24. 115 dweebs
  25. 117 sheep
  26. 74 creeps
  27.  
  28. Method.
  29. Put potatoes into the mixing bowl. Put onions into the mixing bowl. Put
  30. flour into the mixing bowl. Put salt into the mixing bowl. Put bottles
  31. of beer into the mixing bowl. Put acid into the mixing bowl. Put oil into
  32. the mixing bowl. Put pins into the mixing bowl. Put pines into the
  33. mixing bowl. Put onions into the mixing bowl. Put laptops into the mixing
  34. bowl. Put mouses into the mixing bowl. Put keyboards into the mixing
  35. bowl. Put idiots into the mixing bowl. Put flour into the mixing bowl.
  36. Put hackers into the mixing bowl. Put voodoo puppets into the mixing
  37. bowl. Put pins into the mixing bowl. Put onions into the mixing bowl. Put
  38. flour into the mixing bowl. Put hackers into the mixing bowl. Put
  39. crackpipes into the mixing bowl. Put megawatts into the mixing bowl. Put
  40. numbers into the mixing bowl. Put commas into the mixing bowl. Put pins
  41. into the mixing bowl. Put crackpipes into the mixing bowl. Put dweebs into
  42. the mixing bowl. Put sheep into the mixing bowl. Put creeps into the
  43. mixing bowl. Liquify contents of the mixing bowl. Pour contents of the
  44. mixing bowl into the baking dish.
  45.  
  46. Serves 1.

The context is… chef?

Previous Months Challenge

  1. print "one">"two"?1:2;

Well, this one is pretty straight forward, or is it?

The idea i wanted to get out here is again precedence. Perl does calculate strings by their ASCII character number.

However that is specific to the “gt”(greater than) and “lt”(less than) operators. If you took a deeper look and played with the letters you would notice that the result is always 2!

The ‘<’ is a binary operator returning a true and a false. Because “one” and “two” dont really have a numerical value, it is treated in the form of truth. Because it exists it is true! On the other hand a null value would be false, or a numerical 0.

This is just a way of perl trying to always be runnable.

So, as both “one” and “two” are true… “one” is not greater than “two”.

For anyone which isn’t full aware of the ternary operator it is pretty simple and derives from C.

(some statement)?(do if true):(do if false);

VN:F [1.7.9_1023]
Rating: 10.0/10 (7 votes cast)
CAZine: issue 6, December 200910.0107

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14

About the Author