How can I remove nested parentheses recursively in Common LISP Such as
(unnest \'(a b c (d e) ((f) g))) => (a b c d e f g) (unnest \'(a b))
You could define it like this for example:
(defun unnest (x) (labels ((rec (x acc) (cond ((null x) acc) ((atom x) (cons x acc)) (t (rec (car x) (rec (cdr x) acc)))))) (rec x nil)))