Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
elisp random stuff
(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
You can’t perform that action at this time.