Last active
December 11, 2015 08:08
-
-
Save prathamesh-sonpatki/4571194 to your computer and use it in GitHub Desktop.
Code examples from book "An Introduction to Programming in Emacs Lisp"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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