Created
November 20, 2023 23:55
-
-
Save ydm/c51a8d31a6a1af7ffcea92a064851d61 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (setq *xs* '(1 (2 (3 (4 5 6) 7) 8 9 ) 10 11)) | |
| (defun flatten (xs) | |
| (unless (null xs) | |
| (let ((head (car xs)) | |
| (tail (cdr xs))) | |
| ;; (message "head=%s tail=%s" (car xs) (cdr xs)) | |
| (if (atom head) | |
| (cons head (flatten tail)) | |
| (append (flatten head) (flatten tail)))))) | |
| (flatten *xs*) | |
| (1 2 3 4 5 6 7 8 9 10 11) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment