User Guide

GNU Image Manipulation Program
143 / 653
The second thing you need to know is that:
The function name/operator is always the first item in the parentheses, and the rest of the items are parameters to the
function.
El nombre de función/operadores, siempre, lo primero en los paréntesis, y el resto son parámetros de la función.
However, not everything enclosed in parentheses is a function -- they can also be items in a list -- but we’ll get to that later. This
notation is referred to as prefix notation, because the function prefixes everything else. If you’re familiar with postfix notation,
or own a calculator that uses Reverse Polish Notation (such as most HP calculators), you should have no problem adapting to
formulating expressions in Scheme.
The third thing to understand is that:
Mathematical operators are also considered functions, and thus are listed first when writing mathematical expressions.
This follows logically from the prefix notation that we just mentioned.
11.3.1.2 Examples Of Prefix, Infix, And Postfix Notations
Here are some quick examples illustrating the differences between prefix, infix, and postfix notations. We’ll add a 1 and 3 together:
Prefix notation: + 1 3 (the way Scheme will want it)
Infix notation: 1 + 3 (the way we "normally" write it)
Postfix notation: 1 3 + (the way many HP calculators will want it)
11.3.1.3 Practicing In Scheme
Now, let’s practice what we have just learned. Start up GIMP, if you have not already done so, and choose Xtns Script-Fu
Console. This will start up the Script-Fu Console window, which allows us to work interactively in Scheme. In a matter of
moments, the Script-Fu Console will appear:
11.3.1.4 The Script-Fu Console Window
At the bottom of this window is an entry-field entitled Current Command. Here, we can test out simple Scheme commands
interactively. Let’s start out easy, and add some numbers:
(+ 3 5)
Typing this in and hitting Enter yields the expected answer of 8 in the center window.
Now, what if we wanted to add more than one number? The ‘+’ function can take two or more arguments, so this is not a problem:
(+ 3 5 6)
This also yields the expected answer of 14.
So far, so good -- we type in a Scheme statement and it’s executed immediately in the Script-Fu Console window. Now for a
word of caution....
11.3.1.5 Watch Out For Extra Parentheses
If you’re like me, you’re used to being able to use extra parentheses whenever you want to -- like when you’re typing a complex
mathematical equation and you want to separate the parts by parentheses to make it clearer when you read it. In Scheme, you
have to be careful and not insert these extra parentheses incorrectly. For example, say we wanted to add 3 to the result of adding
5 and 6 together:
3 + (5 + 6) + 7 = ?