Saturday, May 22, 2010

How can i define a lisp function which gets the list off all atoms at any level but in the same order?

SO :a list is given and i have to display all atoms from any level,


but in the same order


e.g :


(((A B) C) (D E)) --%26gt; (A B C D E)

How can i define a lisp function which gets the list off all atoms at any level but in the same order?
(defun flatten (lst)


(cond


((null lst) nil)


((atom lst) (list lst))


('t (append (flatten (car lst)) (flatten (cdr lst))))))


No comments:

Post a Comment