Gimp - 2.4 Guía Del Usuario

Descargar
Página de 653
GNU Image Manipulation Program
147 / 653
or simply:
()
Lists can contain atomic values, as well as other lists:
(let*
(
(x
’("The GIMP" (1 2 3) ("is" ("great" () ) ) )
)
)
x
)
Notice that after the first apostrophe, you no longer need to use an apostrophe when defining the inner lists. Go ahead and copy
the statement into the Script-Fu Console and see what it returns.
You should notice that the result returned is not a list of single, atomic values; rather, it is a list of a literal ("The GIMP"), the
list (1 2 3), etc.
11.3.3.2
How To Think Of Lists
It’s useful to think of lists as composed of a ‘head’ and a ‘tail’. The head is the first element of the list, the tail the rest of the list.
You’ll see why this is important when we discuss how to add to lists and how to access elements in the list.
11.3.3.3
Creating Lists Through Concatenation (The Cons Function)
One of the more common functions you’ll encounter is the cons function. It takes a value and prepends it to its second argument,
a list. From the previous section, I suggested that you think of a list as being composed of an element (the head) and the remainder
of the list (the tail). This is exactly how cons functions -- it adds an element to the head of a list. Thus, you could create a list as
follows:
(cons 1 ’(2 3 4) )
The result is the list (1 2 3 4).
You could also create a list with one element:
También, podrías crear una lista con un elemento:
(cons 1 () )
You can use previously declared variables in place of any literals, as you would expect.
11.3.3.4
Defining A List Using The
list
Function
To define a list composed of literals or previously declared variables, use the list function:
(list 5 4 3 a b c)
This will compose and return a list containing the values held by the variables a, b and c. For example:
(let*
(
(a 1)
(b 2)
(c 3)
)
(list 5 4 3 a b c)
)
This code creates the list (5 4 3 1 2 3).