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-eto evaluate a lisp expression in emacsGenerate an Error Message
- Evaluate
(a, b, c, d)will generate an error, typeqto quitFunctions and Arguments
concat number-to-stringThe
messagefunction(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
defunMacro- A typical list function:
|
|
interactive:(interactive "p")uses prefix- let:
|
|
- if:
|
|
-