Deutsch English Français Italiano |
<v7kprk$gqqj$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: HenHanna <HenHanna@devnull.tb> Newsgroups: comp.lang.lisp Subject: Re: Detele repeated in a list Date: Sun, 21 Jul 2024 22:14:26 -0700 Organization: A noiseless patient Spider Lines: 54 Message-ID: <v7kprk$gqqj$1@dont-email.me> References: <v7hj6b$3ooop$1@dont-email.me> <v7hka3$3oudp$1@dont-email.me> <v7khp9$fidq$3@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 22 Jul 2024 07:14:29 +0200 (CEST) Injection-Info: dont-email.me; posting-host="5d36253aba82745bc2fb0c436e5e25c9"; logging-data="551763"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QuhK1xnV5KGyISugvT5PrZullU7j2/68=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:IeWMwOTYd5UFoFdVFzQTvMnVFko= Content-Language: en-US In-Reply-To: <v7khp9$fidq$3@dont-email.me> Bytes: 2488 On 7/21/2024 7:56 PM, HenHanna wrote: > On 7/20/2024 5:21 PM, B. Pym wrote: >> B. Pym wrote: >> >>> Pascal Costanza wrote: >>> >>>> (defun rem-duplicates (list) >>>> (loop for (first . rest) on (append list list) >>>> unless (member first (reverse rest) :test #'equal) >>>> collect first)) >>> >>> Gauche Scheme >>> >>> (define (rem-dups lst) >>> (fold >>> (lambda (x accum) (if (member x accum) accum (cons x accum))) >>> '() >>> lst)) >>> >>> (rem-dups '(0 2 3 4 (8 7) 3 2 0 (8 7))) >>> ===> >>> (4 3 2 0 (8 7)) >> >> Actual result: >> >> ((8 7) 4 3 2 0) >> > > > Gauche doesn't have RemDup built in? i remember that ... Rember was one of the 1st exercises in intro to Lisp Maybe there was a naming convention that suggested that ... Delete is destructive and Remove is not. _________________________________________________________ delete x list :optional elt= [Function] delete! x list :optional elt= [Function] [R7RS list] Equivalent to (remove (lambda (y) (elt= x y)) list) (remove! (lambda (y) (elt= x y)) list) The comparison procedure, elt=, defaults to equal?. delete-duplicates list :optional elt= [Function]