List Processing
Lisp List
- List definition:
'(a, b, c, d, ...)
- lists can be programs AND data
- Atom: indivisible element
- Atoms contain: numbers, symbols, …
Run a Program
'
tells List to do nothing with the list, otherwise, use the first element in the list as the function- Use
C-x C-e
to evaluate a lisp expression in emacsGenerate an Error Message
- Evaluate
(a, b, c, d)
will generate an error, typeq
to quitFunctions and Arguments
concat number-to-string
The
message
function(message "This is a message")
(message "The current buffer is %s" (buffer-name))
Setting the Value of a Variable
- Using
set
:(set 'flowers '(rose violet daisy buttercup))
- Using
setq
:(setq flowers '(rose violet daisy buttercup))
Practicing Evaluation
- To view documentation:
(info "(elisp)Files")
- Each keystroke calls the
self-insert-command
, an interactive function (buffer-size)
(point)
How to Write Function Definitions
The
defun
Macro- A typical list function:
|
|
interactive
:(interactive "p")
uses prefix- let:
|
|
- if:
|
|
-