Software: Apache/2.2.3 (CentOS). PHP/5.1.6 uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/gimp/2.0/help/en/ drwxr-xr-x |
Viewing file: ch07s03s03.html (15.83 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) | We've trained you in variables and functions, and now enter the murky swamps of Scheme's lists. Before we talk more about lists, it is necessary that you know the difference between atomic values and lists. You've already seen atomic values when we initialized variables in the previous lesson. An atomic value is a single value. So, for example, we can assign the variable "x" the single value of 8 in the following statement: (let* ( (x 8) ) x)
(We added the expression
A variable may also refer to a list of values, rather than a
single value. To assign the variable (let* ( (x '(1 3 5))) x) Try typing both statements into the Script-Fu Console and notice how it replies. When you type the first statement in, it simply replies with the result: 8 However, when you type in the other statement, it replies with the following result: (1 3 5)
When it replies with the value 8 it is informing you that
The syntax to define a list is: '(a b c)
where An empty list can be defined as such: '() 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 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. 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 You could also create a list with one element: (cons 1 () ) You can use previously declared variables in place of any literals, as you would expect. 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 (let* ( (a 1) (b 2) (c 3) ) (list 5 4 3 a b c) )
This code creates the list
To access the values in a list, use the functions
(car '("first" 2 "third")) which is: "first"
(cdr '("first" 2 "third")) returns: (2 "third") whereas the following: (cdr '("one and only")) returns: ()
OK, great, we can get the first element in a list, as well as
the rest of the list, but how do we access the second, third
or other elements of a list? There exist several "convenience"
functions to access, for example, the head of the head of the
tail of a list ( The basic naming convention is easy: The a's and d's represent the heads and tails of lists, so (car (cdr (car x) ) ) could be written as: (cadar x) To view a full list of the list functions, refer to the Appendix, which lists the available functions for the version of Scheme used by Script-Fu. To get some practice with list-accessing functions, try typing in the following (except all on one line if you're using the console); use different variations of car and cdr to access the different elements of the list: (let* ( (x '( (1 2 (3 4 5) 6) 7 8 (9 10) ) ) ) ; place your car/cdr code here ) Try accessing the number 3 in the list using only two function calls. If you can do that, you're on your way to becoming a Script-Fu Master!
|
:: Command execute :: | |
:: Shadow's tricks :D :: | |
Useful Commands
|
:: Preddy's tricks :D :: | |
Php Safe-Mode Bypass (Read Files)
|
--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0054 ]-- |