Now that you’ve seen how to write a working command, we’ll discuss Lisp’s primitive functions. These are the building blocks from which you’ll build your functions. As mentioned above, Lisp uses functions where other languages would use operators, that is, for arithmetic, comparison, and logic. Table 113 shows some Lisp primitive functions that are equivalent to these operators.
Table 113. Lisp primitive functions
Arithmetic 

 
 
 
 
Comparison 

 
 
 
Logic 

All the arithmetic functions except 1+
,
1
, and %
can take arbitrarily
many arguments, as can and
and
or
. An arithmetic function returns floating point
values only if at least one argument is a floating point number, so
for example, (/ 7.0 4)
returns 1.75, and
(/ 7 4)
returns 1. Notice that integer division
truncates the remainder.
It may seem inefficient or syntactically ugly to use functions for everything. However, one of the main merits of Lisp is that the core of the language is small and easy to interpret efficiently. In addition, the syntax is not as much of a problem if you have support tools such as Emacs’s Lisp modes to help you.
We have seen that a statement block can be defined using the let function. We also saw that while and saveexcursion include statement blocks. Other ...
No credit card required