RosettaCodeData/Task/Flatten-a-list/Common-Lisp/flatten-a-list-3.lisp

10 lines
274 B
Common Lisp
Raw Permalink Normal View History

2013-10-27 22:24:23 +00:00
(defun flatten (obj)
(let (result)
(labels ((grep (obj)
2015-11-18 06:14:39 +00:00
(cond ((null obj) nil)
2013-10-27 22:24:23 +00:00
((atom obj) (push obj result))
(t (grep (rest obj))
(grep (first obj))))))
(grep obj)
result)))