Joy (programming language)
Joy is a functional programming language that consistently uses the reverse Polish notation .
Joy was developed by Manfred von Thun, who works at La Trobe University in Melbourne (Australia). The core idea is the composition of functions, whereby a number of combiners are available. In simple cases, JOY code looks like FORTH , but the meaningfulness is far more powerful, since data structures (and also program structures) of any complexity can be processed on the stack .
Example: factorial (using the combinator for primitive recursion):
DEFINE fak == [1] [*] primrec
Call example:
5 fak
what is to be understood as follows:
- Put the constant 5 and the lists [1] and [*] on the stack in sequence.
- primrec reads the top three stack elements. If the third equals 0, the second [1] is put on the stack as the result. Otherwise it is decremented by 1, put on the stack, and primrec is called recursively. On the way back, the first element [*] is applied as a function to the top two stack elements and the result (in this case 120) is put back on the stack.