home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / mcl / 1242 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.0 KB  |  38 lines

  1. Path: sparky!uunet!olivea!apple!cambridge.apple.com!hohmann@csmil.umich.edu
  2. From: hohmann@csmil.umich.edu (Luke Hohmann)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: delistifying lists...
  5. Message-ID: <9208171149.AA12077@csmil.umich.edu>
  6. Date: 17 Aug 92 11:49:04 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 26
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10. Original-To: info-macl@cambridge.apple.com
  11.  
  12.  
  13. I needed a function to "delistofy" lists. Here is the function I wrote
  14. and some sample runs. My question to you is: can you submit a faster/better/
  15. cleaner/more robust version of this function? THANKS!
  16.  
  17. ? (defun delistify (l)
  18.   (cond ((null l) nil)
  19.         ((atom l) l)
  20.         ((listp (car l))
  21.          (delistify (append (car l) (cdr l))))
  22.         (t
  23.          (cons (delistify (car l))
  24.                (delistify (cdr l))))))
  25.  
  26. delistify
  27. ? (delistify '(1 2 3))
  28. (1 2 3)
  29. ? (delistify '((1 2 3) 4 5 6))
  30. (1 2 3 4 5 6)
  31. ? (delistify '(1 2 3 (4 5 6)))
  32. (1 2 3 4 5 6)
  33. ? (delistify '((1 2 3) 4 5 6 ((7 8 9))))
  34. (1 2 3 4 5 6 7 8 9)
  35.  
  36.   -- Luke
  37.