Pseudo code

We introduce pseudo-code (not a particular programming language) as a sketch language, and show some typical programming constructs.

Note:
This pseudo-code clearly shows that a while-loop-construction is a recursive if-construction.
It also shows the difference between a for-loop-construction and a while-loop-construction. A for-loop iterates over a set of elements and a while-loop continues as long as a condition holds.
Pitfall:
Too many details. The code looks almost the same as the program in a particular programming language, and so it is not a sketch anymore. The sketching has become the writing of a program directly in a particular programming language.

The constructions we use in our pseudo-code look very similar to constructions that are used in programming languages. This is no surprise, because these programming languages are supposed to support the constructions we use in our design.
The introduction to pseudo-code we gave here can therefor be very useful in an introductionary course on programming.

Although the pseudo-code shown above more or less resembles imperative programming languages, it can also be used for functional languages, like the list processing language Lisp. Then we need a slightly different notation.
Mind though that such a functional language is not different from an imperative language. The computational model for a functional language is the sequential evaluation of list expressions. If we consider a program in an imperative language as a list, we replace any loops with a recursive function, and eliminate the use of placeholders, then it all looks the same. Off course, the reverse is also possible.
We can adept our sketch language to our favourite style for programming.