Skip to content

Instantly share code, notes, and snippets.

@higaki
Last active January 13, 2020 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save higaki/d2cc79ada222ce3715fb48a03e866752 to your computer and use it in GitHub Desktop.
Save higaki/d2cc79ada222ce3715fb48a03e866752 to your computer and use it in GitHub Desktop.
(cons 1 (cons 2 (cons 3 (cons 5 ())))) ; => (1 2 3 5)
(list 1 2 3 5) ; => (1 2 3 5)
(quote (1 2 3 5)) ; => (1 2 3 5)
'(1 2 3 5) ; => (1 2 3 5)
(set 'a '(1 2 3 5)) ; => (1 2 3 5)
(setq a '(1 2 3 5)) ; => (1 2 3 5)
(let ((a '(1 2 3 5)))
(while a
a ; => (1 2 3 5), (2 3 5), (3 5), (5)
(insert (format "\n;; >> %d" (car a)))
(setq a (cdr a))))
;; >> 1
;; >> 2
;; >> 3
;; >> 5
(mapcar (lambda (i) (insert (format "\n;; >> %d" i))) a)
;; >> 1
;; >> 2
;; >> 3
;; >> 5
a ; => (1 2 3 5)
'("matz" . 54) ; => ("matz" . 54)
'(("matz" . 54) ("dhh" . 40)) ; => (("matz" . 54) ("dhh" . 40))
(setq h '(("matz" . 54) ("dhh" . 40)))
(assoc "matz" h) ; => ("matz" . 54)
(cdr (assoc "matz" h)) ; => 54
(assoc-default "matz" h) ; => 54
(assoc "linda" h) ; => nil
(or (assoc-default "linda" h) 0) ; => 0
(setq h '((:matz . 54) (:dhh . 40)))
(assq :matz h) ; => (:matz . 54)
(cdr (assq :matz h)) ; => 54
(or (cdr (assq :linda h)) 0) ; => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment