Next: Remark:
Up: Basic Abstractions
Previous: Basic Abstractions
Contents
Start
The IF- Abstraction
One of the most basic operation in any programming language
is to make a decision, to select a block of code
depending on the truth value of a certain argument.
Such an operation people have in mind, when they talk about IF-statements, IF-THEN-ELSE-constructs, alternative structures and a few more.
We can very well say that the IF-statement has the function to select code to be evaluated or executed. The IF-statement therefore is a function taking three arguments:
- a condition having a certain truth value (true or false),
- the first block of code and
- the second block of code.
Because the selection of the code block to be evaluated or executed depends on the first argument, we can look at the first argument as a
selector.
Having thus analyzed the essence of an IF-function we may code it
as a `lambda abstraction':
(define if (lambda (sel a b)
(sel a b)))
|
Subsections
Georg P. Loczewski
2004-03-05