Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #218: The UPS doesn't have a battery backup.


comp / comp.lang.lisp / Re: Detele repeated in a list

SubjectAuthor
* Re: Detele repeated in a listB. Pym
`* Re: Detele repeated in a listB. Pym
 +* Re: Detele repeated in a listHenHanna
 |`- Re: Detele repeated in a listHenHanna
 `- Re: Detele repeated in a listB. Pym

1
Subject: Re: Detele repeated in a list
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Sun, 21 Jul 2024 00:02 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Detele repeated in a list
Date: Sun, 21 Jul 2024 00:02:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <v7hj6b$3ooop$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Sun, 21 Jul 2024 02:02:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d3ba06d1e9c3f008981fe6f00607550b";
logging-data="3957529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ermEXW09aRp8zDyhxaMP3"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:UMdjeaSHypg9FiZPpquS98+BoQQ=
View all headers

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))

Subject: Re: Detele repeated in a list
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Sun, 21 Jul 2024 00:21 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Detele repeated in a list
Date: Sun, 21 Jul 2024 00:21:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <v7hka3$3oudp$1@dont-email.me>
References: <v7hj6b$3ooop$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Sun, 21 Jul 2024 02:21:28 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7b0a8e365f2abfcb427a2f6d66b0136c";
logging-data="3963321"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++QCp5ffcpkwrp8UFjPq04"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:JTtq+QFzewkA7jLvKD5Yat57g70=
View all headers

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)

Subject: Re: Detele repeated in a list
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 22 Jul 2024 02:56 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp
Subject: Re: Detele repeated in a list
Date: Sun, 21 Jul 2024 19:56:39 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <v7khp9$fidq$3@dont-email.me>
References: <v7hj6b$3ooop$1@dont-email.me> <v7hka3$3oudp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 22 Jul 2024 04:56:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5d36253aba82745bc2fb0c436e5e25c9";
logging-data="510394"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183vgk5X3IWTDo6WJgogiqW+C8yv+bIZZc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:y4YNF334N0uq+fiVqh/VFDEwyfI=
In-Reply-To: <v7hka3$3oudp$1@dont-email.me>
Content-Language: en-US
View all headers

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?

Subject: Re: Detele repeated in a list
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 22 Jul 2024 05:14 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
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>
View all headers

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]

Subject: Re: Detele repeated in a list
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Thu, 15 Aug 2024 01:06 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Detele repeated in a list
Date: Thu, 15 Aug 2024 01:06:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <v9jk9o$lrgv$1@dont-email.me>
References: <v7hj6b$3ooop$1@dont-email.me> <v7hka3$3oudp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 15 Aug 2024 03:06:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7e5ecf5f7253603983f636ec904f7241";
logging-data="716319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4LkR23JnqkakcsuylTum1"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:0RzvAKgAShj4Scm/3L1apwdpSko=
View all headers

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)

newLISP

(define (rem-dups lst)
;; Using "apply" for "reduce" or "fold".
(apply
(fn (accum x) (if (member x accum) accum (push x accum -1)))
(cons '() lst)
2))

(rem-dups '(0 2 3 4 (8 7) 3 2 0 (8 7)))

(0 2 3 4 (8 7))

1

rocksolid light 0.9.8
clearnet tor