Skip to content

Instantly share code, notes, and snippets.

@prathamesh-sonpatki
Last active December 11, 2015 08:08
Show Gist options
  • Save prathamesh-sonpatki/4571194 to your computer and use it in GitHub Desktop.
Save prathamesh-sonpatki/4571194 to your computer and use it in GitHub Desktop.
Code examples from book "An Introduction to Programming in Emacs Lisp"
;; 1.1.1 Lisp atoms
;; If a list is preceded by single quote, we are telling lisp interpreter to take it as it is
'(sachin
rahul
saurav
laxman)
;; If a list is not preceded by single quote, lisp interpreter treats first atom of the list as a function,
;; and passes all the remaining atoms as arguments to it, and returns result of the function
(+ 2 2)
'(this list has (list inside it))
()
'(empty list above)
'(foo)
'(this is a list made up of symbols and numbers such as 0 1 2)
'(this is example of a quoted "atom")
'("quoted text can contain punctuation marks such as . ? ; ,")
'(quoted atom is "string")
'(3 kinds of atoms so far (numbers) ("strings") (symbols))
;; 1.1.2 Whitespace in Lists
'(amount of whitespace in lists does not
matter)
'(there should be atleast one space between atoms in a list)
;; 1.3 Generating error
(this is not quoted so will generate error)
;;Debugger entered--Lisp error: (void-function this)
;; (this is not quoted so will generate error)
;; eval((this is not quoted so will generate error) nil)
;; eval-last-sexp-1(nil)
;; eval-last-sexp(nil)
;; call-interactively(eval-last-sexp nil nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment