Last active
August 20, 2022 06:09
-
-
Save biofermin2/70830e362f1840b89c7158030a2b3b7a to your computer and use it in GitHub Desktop.
convert struct to list , list to struct.
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
(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