newbie exploring better ways
- From: vijay <vijaykcm@xxxxxxxxx>
- Date: Tue, 29 Jan 2008 19:42:21 -0800 (PST)
The following function removes only the first occurrence of an element
from a list. Is this very different than how experienced Lispers do
things? The function is part of my homework assignment. However, my
homework is just to write a function that does its job. I am trying to
learn if there are better ways to do it.
(defun remv (item l)
"a function to remove (without modifying the list) the FIRST
occurrence of a given element"
(let ((result-list nil)(flag 0))
(dolist (curr l)
(if (equalp curr item)
( if(equalp flag 1) (push curr result-list) (setq flag 1))
(push curr result-list)))
(reverse result-list)))
.
- Follow-Ups:
- Re: newbie exploring better ways
- From: Mark Tarver
- Re: newbie exploring better ways
- From: Kent M Pitman
- Re: newbie exploring better ways
- From: Ken Tilton
- Re: newbie exploring better ways
- From: Madhu
- Re: newbie exploring better ways
- From: Griff
- Re: newbie exploring better ways
- Prev by Date: Re: better way to enumerate
- Next by Date: Re: newbie exploring better ways
- Previous by thread: Paul Graham's Arc is released today... what is the long term impact?
- Next by thread: Re: newbie exploring better ways
- Index(es):
Relevant Pages
|
|