Introduction
------------
This workspace was written as a test during the development of D-functions. The
application is not in itself useful other than to provide examples of some cod-
ing techniques that were discovered along the way.
The result illustrates that while D-functions are extremely simple, they can be
used to write significant programs - in this case a compiler/interpreter for an
admittedly almost negligible lazy functional language.
It is worth remarking that during the coding of this workspace, it wasn't found
necessary to use a branch or control structure other than D-functions' own
Guard. Perhaps more surprising: there isn't a single instance of a destructive
assignment. In other words, a name is assigned only once; nothing varies, so
strictly speaking, there are no variables!
Destructive assignments are certainly allowed within D-functions, but Functional
Programming purists tend to avoid them in the same way that we try to avoid too
much branching. If we adhere to this convention, we can read the symbol '←' as
"is". For example:
N←1+M ⍝ "N IS one-more-than M" states the value of N, whereas:
N←1+N ⍝ "N IS one-more-than N" is a contradiction.
To see some examples of D-functions, examine and trace those defined in this
workspace. For example, trace:
parse'a=bc'
If (just for fun), you would like to experiment with the little language itself,
there's a sample script 'Example'. To see it evaluated, type:
min Example
Min takes either a null vector right argument or a character matrix script for
processing prior to interactive input. Definitions accumulated during a Min
session are returned on exit as a shy result. This environment can be reinput
to a subsequent session via min's optional left argument.
For more detail on the background of min:
)ed Background
Exercises
---------
You might like to write min scripts for :
- Predecessor (decrement).
- Parity: even 0, odd 1.
- Difference (subtraction).
- Integer quotient and remainder.
- Relational functions: < ≤ = ≥ > ≠.
- Boolean functions: ∧ ∨ ⍲ ⍱ ~.
- N'th Fibonacci number.
- Highest common factor.
- Prime: returns 1 if argument is prime.
Who knows, one day we might see:
"$$$$$ - Wanted: Min Programmer - $$$$$"
"This year's Min conference will be held in sunny ···"
"comp.lang.min"
···
:-)
Back to: contents