home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!apple!cambridge.apple.com!hohmann@csmil.umich.edu
- From: hohmann@csmil.umich.edu (Luke Hohmann)
- Newsgroups: comp.lang.lisp.mcl
- Subject: delistifying lists...
- Message-ID: <9208171149.AA12077@csmil.umich.edu>
- Date: 17 Aug 92 11:49:04 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 26
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
- Original-To: info-macl@cambridge.apple.com
-
-
- I needed a function to "delistofy" lists. Here is the function I wrote
- and some sample runs. My question to you is: can you submit a faster/better/
- cleaner/more robust version of this function? THANKS!
-
- ? (defun delistify (l)
- (cond ((null l) nil)
- ((atom l) l)
- ((listp (car l))
- (delistify (append (car l) (cdr l))))
- (t
- (cons (delistify (car l))
- (delistify (cdr l))))))
-
- delistify
- ? (delistify '(1 2 3))
- (1 2 3)
- ? (delistify '((1 2 3) 4 5 6))
- (1 2 3 4 5 6)
- ? (delistify '(1 2 3 (4 5 6)))
- (1 2 3 4 5 6)
- ? (delistify '((1 2 3) 4 5 6 ((7 8 9))))
- (1 2 3 4 5 6 7 8 9)
- ?
-
- -- Luke
-