Created
March 22, 2018 01:10
-
-
Save orb/3ba47be961e24dd53808f71fa31ebcc7 to your computer and use it in GitHub Desktop.
elisp random stuff
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 flatten (l) | |
(cond | |
((null l) nil) | |
((listp l) (append (flatten (car l)) | |
(flatten (cdr l)))) | |
(t (list l)))) | |
(flatten '()) | |
(flatten 1) | |
(flatten '(1 . 2)) | |
(flatten '(1 2 3)) | |
(flatten '((1 2 3) 4 (5 6 7 8) 9 10 (11))) | |
(flatten '(\t (\h \e) (((((("earth")))))))) | |
(flatten '(a ((b) c) d )) | |
(defun count-syms (lst &optional c) | |
(cond | |
((null c) (count-syms lst 0)) | |
((null lst) c) | |
((symbolp (car lst)) (count-syms (cdr lst) (+ c 1))) | |
(t (count-syms (cdr lst) c)))) | |
(count-syms (number-sequence 1 1000)) | |
(count-syms '(1 2 3)) | |
(count-syms '(1 hi 3)) | |
(count-syms '(this (is) "a" test)) | |
(count-syms '(this (is) "a" test)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment