Chapter 5. Making New Functions

Function in Ripley are just executable arrays that have been assigned as elements in the user dictionary. To define a function we use an executable array and the 'def' operator that we used in the variable assignment section from before. Here is an example where I create a function that prints "Hello World!":

Example 5-1. Hello World function

/hello { "Hello World!" print } def
hello

Arguments to functions are implemented using the operand stack, just like every other Ripley function. Here is an example add10 function, which adds 10 to whatever you give it:

Example 5-2. Add 10 function

/add10 { 10 add } def
20 add10 print
100 add10 print