Skip to content

Instantly share code, notes, and snippets.

@werelax
Created May 7, 2016 09:13
Show Gist options
  • Save werelax/bf28190efc0e081637b0ac7d28848f48 to your computer and use it in GitHub Desktop.
Save werelax/bf28190efc0e081637b0ac7d28848f48 to your computer and use it in GitHub Desktop.
Common Lisp utilities
(defmacro getf-in (list &rest keys)
(reduce (lambda (acc el) `(getf ,acc ,el))
keys :initial-value list))
;; example
(defparameter jarl '(:a 1 :b 2 :c (:d (:e "yeah"))))
(getf-in jarl :c :d :e) ; => "yeah"
(setf (getf-in jarl :c :d :e) "something else")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment