def joy(stack, expression, dictionary, viewer=None):
'''Evaluate a Joy expression on a stack.
-<<<<<<< working copy
This function iterates through a sequence of terms which are either
literals (strings, numbers, sequences of terms) or function symbols.
Literals are put onto the stack and functions are looked up in the
dictionary and executed.
-=======
- This function iterates through a sequence of terms which are either
- literals (strings, numbers, sequences of terms) or function symbols.
- Literals are put onto the stack and functions are looked up in the
- disctionary and executed.
->>>>>>> merge rev
The viewer is a function that is called with the stack and expression
on every iteration, its return value is ignored.