[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is there a lisp function as follows?
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: Re: is there a lisp function as follows?
- From: gat@aig.jpl.nasa.gov (Erann Gat)
- Date: Thu, 31 Aug 95 11:41:33 PDT
(defun split (item l)
"Returns two values - the list l up to the first occurence of item, and
the rest of l after and including item. Split is destructive."
(let ( (rest (member item l)) )
(setf (nthcdr (- (length l) (length rest)) l) nil)
(values l rest)))
? (setf l '(1 2 3 4 5))
(1 2 3 4 5)
? (split 3 l)
(1 2)
(3 4 5)
? l
(1 2)
? (setf l '(1 2 3 4 5))
(1 2 3 4 5)
? (split 7 l)
(1 2 3 4 5)
NIL
?
Erann Gat
gat@jpl.nasa.gov