Commit ce1a2864 by nasciiboy

### ¸.·´¯`·¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>

parent 7541c557
 ... ... @@ -1267,7 +1267,7 @@ Multiply NUMBER by seven.

Here, the true-or-false-test is the expression:

(equal characteristic 'fierce)

In Lisp, equal is a function that determines whether its first argument is equal to its second argument. The second argument is the quoted symbol 'fierce and the first argument is the value of the symbol characteristic---in other words, the argument passed to this function.

In Lisp, equal is a function that determines whether its first argument is equal to its second argument. The second argument is the quoted symbol 'fierce and the first argument is the value of the symbol characteristic––in other words, the argument passed to this function.

In the first exercise of type-of-animal, the argument fierce is passed to type-of-animal. Since fierce is equal to fierce, the expression, (equal characteristic 'fierce), returns a value of true. When this happens, the if evaluates the second argument or then-part of the if: (message "It's tiger!").

On the other hand, in the second exercise of type-of-animal, the argument zebra is passed to type-of-animal. zebra is not equal to fierce, so the then-part is not evaluated and nil is returned by the if expression.

... ... @@ -1309,7 +1309,7 @@ Multiply NUMBER by seven.

The expression that tests for truth is interpreted as true if the result of evaluating it is a value that is not nil. In other words, the result of the test is considered true if the value returned is a number such as 47, a string such as "hello", or a symbol (other than nil) such as flowers, or a list (so long as it is not empty), or even a buffer!

Before illustrating a test for truth, we need an explanation of nil.

In Emacs Lisp, the symbol nil has two meanings. First, it means the empty list. Second, it means false and is the value returned when a true-or-false-test tests false. nil can be written as an empty list, (), or as nil. As far as the Lisp interpreter is concerned, () and nil are the same. Humans, however, tend to use nil for false and () for the empty list.

In Emacs Lisp, any value that is not nil---is not the empty list––is considered true. This means that if an evaluation returns something that is not an empty list, an if expression will test true. For example, if a number is put in the slot for the test, it will be evaluated and will return itself, since that is what numbers do when evaluated. In this conditional, the if expression will test true. The expression tests false only when nil, an empty list, is returned by evaluating the expression.

In Emacs Lisp, any value that is not nil––is not the empty list––is considered true. This means that if an evaluation returns something that is not an empty list, an if expression will test true. For example, if a number is put in the slot for the test, it will be evaluated and will return itself, since that is what numbers do when evaluated. In this conditional, the if expression will test true. The expression tests false only when nil, an empty list, is returned by evaluating the expression.

You can see this by evaluating the two expressions in the following examples.

In the first example, the number 4 is evaluated as the test in the if expression and returns itself; consequently, the then-part of the expression is evaluated and returned: ‘true’ appears in the echo area. In the second example, the nil indicates false; consequently, the else-part of the expression is evaluated and returned: ‘false’ appears in the echo area.

(if 4
...  ...  @@ -1958,7 +1958,7 @@ Beginning of buffer is position (point-min), end is (point-max).
(setq buffer (get-buffer buffer)))

The first argument to or is the expression (bufferp buffer). This expression returns true (a non-nil value) if the buffer is actually a buffer, and not just the name of a buffer. In the or expression, if this is the case, the or expression returns this true value and does not evaluate the next expression––and this is fine with us, since we do not want to do anything to the value of buffer if it really is a buffer.

On the other hand, if the value of (bufferp buffer) is nil, which it will be if the value of buffer is the name of a buffer, the Lisp interpreter evaluates the next element of the or expression. This is the expression (setq buffer (get-buffer buffer)). This expression returns a non-nil value, which is the value to which it sets the variable buffer---and this value is a buffer itself, not the name of a buffer.

On the other hand, if the value of (bufferp buffer) is nil, which it will be if the value of buffer is the name of a buffer, the Lisp interpreter evaluates the next element of the or expression. This is the expression (setq buffer (get-buffer buffer)). This expression returns a non-nil value, which is the value to which it sets the variable buffer––and this value is a buffer itself, not the name of a buffer.

The result of all this is that the symbol buffer is always bound to a buffer itself rather than to the name of a buffer. All this is necessary because the set-buffer function in a following line only works with a buffer itself, not with the name to a buffer.

Incidentally, using or, the situation with the usher would be written like this:

(or (holding-on-to-guest) (find-and-take-arm-of-guest))
...  ...  @@ -7901,7 +7901,7 @@ Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.

16

I also run more modern window managers, such as Enlightenment, Gnome, or KDE; in those cases, I often specify an image rather than a plain color.

... ...
 ... ... @@ -2442,7 +2442,7 @@ promoting software freedom.” In Lisp, @c{equal} is a function that determines whether its first argument is equal to its second argument. The second argument is the quoted symbol @c{'fierce} and the first argument is the value of the symbol @c{characteristic}---in other words, the argument passed to this symbol @c{characteristic}––in other words, the argument passed to this function. In the first exercise of @c{type-of-animal}, the argument @c{fierce} is ... ... @@ -2547,7 +2547,7 @@ promoting software freedom.” @c{()} and @c{nil} are the same. Humans, however, tend to use @c{nil} for false and @c{()} for the empty list. In Emacs Lisp, any value that is not @c{nil}---is not the empty list––is In Emacs Lisp, any value that is not @c{nil}––is not the empty list––is considered true. This means that if an evaluation returns something that is not an empty list, an @c{if} expression will test true. For example, if a number is put in the slot for the test, it will be evaluated and will ... ... @@ -3882,7 +3882,7 @@ promoting software freedom.” interpreter evaluates the next element of the @c{or} expression. This is the expression @c{(setq buffer (get-buffer buffer))}. This expression returns a non-@c{nil} value, which is the value to which it sets the variable @c{buffer}---and this value is a buffer itself, not the name of variable @c{buffer}––and this value is a buffer itself, not the name of a buffer. The result of all this is that the symbol @c{buffer} is always bound to a ... ... @@ -15807,6 +15807,6 @@ promoting software freedom.” > emacs -Q -D < srci.. :: @n{16} :: I also run more modern window managers, such as Enlightenment, :: @N{16} :: I also run more modern window managers, such as Enlightenment, Gnome, or KDE; in those cases, I often specify an image rather than a plain color.
 ... ... @@ -506,7 +506,7 @@

GNU Emacs te ayuda a escribir listas

Cuando se escribe una expresión Lisp en GNU Emacs usando el modo de Interacción Lisp o el modo Emacs Lisp, están disponibles varios comandos para formatear la expresión Lisp, de modo que sea fácil de leer. Por ejemplo, presionando la tecla TAB automáticamente se indenta la línea donde se encuetra el cursor a la cantidad correcta. Un comando para indentar apropiadamente el código en una región suele vincularse a M-C-\. La indentación está diseñada de modo que se pueda ver qué elementos pertenecen a cada lista––los elementos de una sublista están más indentados que los elementos de la lista adjunta.

Cuando se escribe una expresión Lisp en GNU Emacs usando el modo de Interacción Lisp o el modo Emacs Lisp, están disponibles varios comandos para formatear la expresión Lisp, de modo que sea fácil de leer. Por ejemplo, presionando la tecla TAB automáticamente se indenta la línea donde se encuentra el cursor a la cantidad correcta. Un comando para indentar apropiadamente el código en una región suele vincularse a M-C-\. La indentación está diseñada de modo que se pueda ver qué elementos pertenecen a cada lista––los elementos de una sublista están más indentados que los elementos de la lista adjunta.

Además, al escribir un paréntesis de cierre, Emacs mueve el cursor momentáneamente hacia el parentesis de apertura correspondiente, para que puedas ver cual es. Esto es muy útil, ya que cada lista que escribas en Lisp debe tener su paréntesis de cierre que coincida con su paréntesis de apertura. (Consulta la Seccion Modos Mayores en El Manual de GNU Emacs, para más información sobre los modos de Emacs.)

Ejecutar un programa

... ...
 ... ... @@ -376,7 +376,7 @@ and promoting software freedom.” Interacción Lisp o el modo Emacs Lisp, están disponibles varios comandos para formatear la expresión Lisp, de modo que sea fácil de leer. Por ejemplo, presionando la tecla @k{TAB} automáticamente se indenta la línea donde se encuetra el cursor a la cantidad correcta. Un comando para indentar donde se encuentra el cursor a la cantidad correcta. Un comando para indentar apropiadamente el código en una región suele vincularse a @k{M-C-\}. La indentación está diseñada de modo que se pueda ver qué elementos pertenecen a cada lista––los elementos de una sublista están más indentados que los ... ...
 ... ... @@ -692,7 +692,7 @@ and promoting software freedom.” Interacción Lisp o el modo Emacs Lisp, están disponibles varios comandos para formatear la expresión Lisp, de modo que sea fácil de leer. Por ejemplo, presionando la tecla @k{TAB} automáticamente se indenta la línea donde se encuetra el cursor a la cantidad correcta. Un comando para indentar donde se encuentra el cursor a la cantidad correcta. Un comando para indentar apropiadamente el código en una región suele vincularse a @k{M-C-\}. La indentación está diseñada de modo que se pueda ver qué elementos pertenecen a cada lista––los elementos de una sublista están más indentados que los ... ... @@ -4403,7 +4403,7 @@ and promoting software freedom.” # In Lisp, @c{equal} is a function that determines whether its first # argument is equal to its second argument. The second argument is the # quoted symbol @c{'fierce} and the first argument is the value of the # symbol @c{characteristic}---in other words, the argument passed to this # symbol @c{characteristic}––in other words, the argument passed to this # function. En Lisp, @c{equal} es una función que determina si su primer argumento es igual al segundo. El segundo argumento es el símbolo citado @c{'fiero} y el ... ... @@ -4596,7 +4596,7 @@ and promoting software freedom.” humanos, sin embargo, tienden a usar @c{nil} para falso y @c{()} para lista vacía. # In Emacs Lisp, any value that is not @c{nil}---is not the empty list––is # In Emacs Lisp, any value that is not @c{nil}––is not the empty list––is # considered true. This means that if an evaluation returns something that # is not an empty list, an @c{if} expression will test true. For example, # if a number is put in the slot for the test, it will be evaluated and will ... ... @@ -6953,7 +6953,7 @@ and promoting software freedom.” # interpreter evaluates the next element of the @c{or} expression. This is # the expression @c{(setq buffer (get-buffer buffer))}. This expression # returns a non-@c{nil} value, which is the value to which it sets the # variable @c{buffer}---and this value is a buffer itself, not the name of # variable @c{buffer}––and this value is a buffer itself, not the name of # a buffer. Por otro lado, si el valor de @c{(bufferp buffer)} es @c{nil}, que lo sera si el valor de @c{buffer} es el nombre de un buffer, el intérprete Lisp ... ... @@ -28286,7 +28286,7 @@ and promoting software freedom.” > emacs -Q -D < srci.. # :: @n{16} :: I also run more modern window managers, such as Enlightenment, # :: @N{16} :: I also run more modern window managers, such as Enlightenment, # Gnome, or KDE; in those cases, I often specify an image rather than a # plain color. :: @N{16} :: También ejecuto gestores de ventanas más modernos,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!