From: Arseny Slobodjuck
Subject: deleting a nth element of a list
Date: 
Message-ID: <392ccbf1.12603723@news.vtc.ru>
Which is the best way to delete some element, whose number is known
from a list  ? Is it the following ?

(delete-if (lambda (x) t) some-list :start i :count 1)

thanks

From: Erik Naggum
Subject: Re: deleting a nth element of a list
Date: 
Message-ID: <3168226623807923@naggum.no>
* Arseny Slobodjuck
| Which is the best way to delete some element, whose number is known
| from a list?  Is it the following?

  Clever solution, but I tend to think that plain old ordinary list
  hacking is simpler:

(defun delete-nth (n list)
  (if (zerop n)
    (cdr list)
    (let ((cons (nthcdr (1- n) list)))
      (if cons
	(setf (cdr cons) (cddr cons))
	cons))))

#:Erik
-- 
  If this is not what you expected, please alter your expectations.
From: Francis Leboutte
Subject: Re: deleting a nth element of a list
Date: 
Message-ID: <k8tpis8npeeiui4e27b0mljok26vl0chml@4ax.com>
Erik Naggum <····@naggum.no> wrote:

>* Arseny Slobodjuck
>| Which is the best way to delete some element, whose number is known
>| from a list?  Is it the following?
>
>  Clever solution, but I tend to think that plain old ordinary list
>  hacking is simpler:
>
>(defun delete-nth (n list)
>  (if (zerop n)
>    (cdr list)
>    (let ((cons (nthcdr (1- n) list)))
>      (if cons
>	(setf (cdr cons) (cddr cons))
>	cons))))

Would prefer this :
(defun delete-position (n list)
  (if (zerop n)
      (cdr list)
    (let ((cons (nthcdr (1- n) list)))
      (when cons
        (setf (cdr cons) (cddr cons)))
      list)))

>#:Erik

--
Francis Leboutte
··@algo.be   www.algo.be   +32-(0)4.388.39.19
From: Markus B. Kr�ger
Subject: Re: deleting a nth element of a list
Date: 
Message-ID: <du3vgzk2tiy.fsf@verden.pvv.ntnu.no>
Erik Naggum <····@naggum.no> writes:

> * Arseny Slobodjuck
> | Which is the best way to delete some element, whose number is known
> | from a list?  Is it the following?
> 
>   Clever solution, but I tend to think that plain old ordinary list
>   hacking is simpler:

However, the delete-if solution would work for any sequence, not just
lists.

-- 
 '-------------------  Markus Bjartveit Kr�ger  ---------------------`
'                                                                     `
` E-mail: ·······@pvv.org           WWW: http://www.pvv.org/~markusk/ '
 )-------------------------------------------------------------------(