Skip to content

Instantly share code, notes, and snippets.

@biofermin2
Last active August 20, 2022 06:09
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 biofermin2/70830e362f1840b89c7158030a2b3b7a to your computer and use it in GitHub Desktop.
Save biofermin2/70830e362f1840b89c7158030a2b3b7a to your computer and use it in GitHub Desktop.
convert struct to list , list to struct.
(defun struct->list (instance)
(let* ((str (format nil "~s" instance))
(sexp (read-from-string (subseq str 2))))
(values (cdr sexp)
(car sexp)))) ; => STRUCT->LIST
(defun list->struct (name lst)
(read-from-string (format nil "#S~s" (cons name lst)))) ; =>LIST->STRUCT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment