Joy (programming language): Difference between revisions

Content deleted Content added
flagrant abuse of superlative
m Corrected link to disambiguation page. (you can help!)
Line 17:
DEFINE square == dup * .
 
To explain: In Joy, everything is a function that takes a [[stack (computingdata structure)|stack]] as an argument and returns a stack as a result. For instance, the number 5 is not, as it might appear to be, an integer constant, but instead a short program that pushes the number 5 onto the stack. The + operator pops two numbers off the stack and pushes their sum. The dup operator simply duplicates the top element of the stack by pushing a copy of it. So this definition of the square function says to make a copy of the top element and then multiply the two top elements, leaving the square of the original top element on top of the stack. There is no need for a formal parameter at all. This design gives Joy conciseness and power, as illustrated by this definition of [[quicksort]]:
 
<pre>