Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #1: clock speed


comp / comp.lang.lisp / Re: Rather simple list/set operation [?]

SubjectAuthor
* Rather simple list/set operation [?]B. Pym
+* Re: Rather simple list/set operation [?]Jeff Barnett
|+* Re: Rather simple list/set operation [?]Jens Kallup
||`* Re: Rather simple list/set operation [?]Jeff Barnett
|| `- Re: Rather simple list/set operation [?]Jens Kallup
|`- Re: Rather simple list/set operation [?]Madhu
`- Re: Rather simple list/set operation [?]HenHanna

1
Subject: Rather simple list/set operation [?]
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Fri, 7 Jun 2024 07:56 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Rather simple list/set operation [?]
Date: Fri, 7 Jun 2024 07:56:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <v3uefj$202pe$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Fri, 07 Jun 2024 09:56:53 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="07dcd4a0cf86bbbfcc45b5567a2425b6";
logging-data="2100014"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RIVe32xWne7eKzO97HdKk"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:wlr2JwxnxA/wZf7E83nfdhDApgo=
View all headers

From: Drew Krause
Subject: rather simple list/set operation
Date: Tue, 3 Jan 2012 19:01:19 -0600

Drew Krause wrote:

> Maybe someone can help me with this?
>
> I start with a list, e.g.
>
> ((0) (1 3) (1 2) (4 6) (5 7) (7 8))
>
>
> and want all members of intersecting lists to appear in the same sublist:
>
> => ((0) (1 2 3) (4 6) (5 7 8))

Gauche Scheme:

(use srfi-1) ; "lset-" functions
(use srfi-42) ; do-ec

(define (coalesce lists)
(define accum '())
(do-ec (:list x lists)
(receive
(miss hit)
(partition (lambda (y) (null? (lset-intersection equal? x y)))
accum)
(set! accum
(cons (apply lset-union equal? x hit) miss))))
accum)

(coalesce '((2 4) (8 9) (4 5 8)))
===>
((2 9 4 5 8))

(coalesce '((2 4) (3 9) (5 6) (2 3)))
===>
((4 9 2 3) (5 6))

(coalesce '((0) (1 3) (1 2) (4 6) (5 7) (7 8)))
===>
((5 7 8) (4 6) (3 1 2) (0))

(coalesce '((2 4) (3 9) (5 6) (2 3) (55 66) (0) (66 6)))
===>
((5 55 66 6) (0) (4 9 2 3))

Subject: Re: Rather simple list/set operation [?]
From: Jeff Barnett
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Fri, 7 Jun 2024 18:07 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jbb@notatt.com (Jeff Barnett)
Newsgroups: comp.lang.lisp
Subject: Re: Rather simple list/set operation [?]
Date: Fri, 7 Jun 2024 12:07:33 -0600
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <v3vi98$25sr1$1@dont-email.me>
References: <v3uefj$202pe$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 07 Jun 2024 20:07:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cae2a0a11fc6e61f2acd08c5e1649632";
logging-data="2290529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19U0Pz5NEkT4a+R4foLBx0zza/fJHAnTd0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:usqNcqkHpm74Ov1DdNTyE/QJUE0=
In-Reply-To: <v3uefj$202pe$1@dont-email.me>
Content-Language: en-US
View all headers

On 6/7/2024 1:56 AM, B. Pym wrote:
>
> From: Drew Krause
> Subject: rather simple list/set operation
> Date: Tue, 3 Jan 2012 19:01:19 -0600
>
>
> Drew Krause wrote:
>
>> Maybe someone can help me with this?
>>
>> I start with a list, e.g.
>>
>> ((0) (1 3) (1 2) (4 6) (5 7) (7 8))
>>
>>
>> and want all members of intersecting lists to appear in the same sublist:
>>
>> => ((0) (1 2 3) (4 6) (5 7 8))
I think the problem definition is ambiguous and not clarified by the
example. Consider the following input lists:
((0 1) (1 2) (2 3)),
((0 1) (0 2) (0 3)).
Any idea what Krause had in mind?
--
Jeff Barnett

Subject: Re: Rather simple list/set operation [?]
From: Jens Kallup
Newsgroups: comp.lang.lisp
Organization: kallup non-profit
Date: Fri, 7 Jun 2024 18:31 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: paule32.jk@gmail.com (Jens Kallup)
Newsgroups: comp.lang.lisp
Subject: Re: Rather simple list/set operation [?]
Date: Fri, 7 Jun 2024 20:31:02 +0200
Organization: kallup non-profit
Lines: 3
Message-ID: <lch1v6Fpo4eU5@mid.individual.net>
References: <v3uefj$202pe$1@dont-email.me> <v3vi98$25sr1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net tJNPlkWoN3ihDUt6zU/WigQjkWDZpHJtiHOvbNCYPB2tv7ND8x
Cancel-Lock: sha1:qtfGTuJeo5IAvusfQBxBRmcJe+Y= sha256:hov6CHrBxgdQdl/OXomQg+eJoEExziOeULo1U1tIOLo=
User-Agent: Mozilla Thunderbird
Content-Language: en-US, de-DE
In-Reply-To: <v3vi98$25sr1$1@dont-email.me>
X-Antivirus: Avast (VPS 240607-6, 7.6.2024), Outbound message
X-Antivirus-Status: Clean
View all headers

Am 2024-06-07 um 20:07 schrieb Jeff Barnett:
> Any idea what Krause had in mind?
linked lists

Subject: Re: Rather simple list/set operation [?]
From: Jeff Barnett
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Fri, 7 Jun 2024 18:38 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jbb@notatt.com (Jeff Barnett)
Newsgroups: comp.lang.lisp
Subject: Re: Rather simple list/set operation [?]
Date: Fri, 7 Jun 2024 12:38:40 -0600
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <v3vk3k$26746$1@dont-email.me>
References: <v3uefj$202pe$1@dont-email.me> <v3vi98$25sr1$1@dont-email.me>
<lch1v6Fpo4eU5@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 07 Jun 2024 20:38:44 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cae2a0a11fc6e61f2acd08c5e1649632";
logging-data="2301062"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1GtsqZTD1ncGB721qoAAA73G3/rsX0JE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pAozDT/6M6tRkn1SBnN6dKfb8nA=
Content-Language: en-US
In-Reply-To: <lch1v6Fpo4eU5@mid.individual.net>
View all headers

On 6/7/2024 12:31 PM, Jens Kallup wrote:
> Am 2024-06-07 um 20:07 schrieb Jeff Barnett:
>> Any idea what Krause had in mind?
> linked lists

I'd love to see and Krause jointly specify a problem.
--
Jeff Barnett

Subject: Re: Rather simple list/set operation [?]
From: Jens Kallup
Newsgroups: comp.lang.lisp
Organization: kallup non-profit
Date: Fri, 7 Jun 2024 19:36 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: paule32.jk@gmail.com (Jens Kallup)
Newsgroups: comp.lang.lisp
Subject: Re: Rather simple list/set operation [?]
Date: Fri, 7 Jun 2024 21:36:44 +0200
Organization: kallup non-profit
Lines: 36
Message-ID: <lch5qcFrcpjU1@mid.individual.net>
References: <v3uefj$202pe$1@dont-email.me> <v3vi98$25sr1$1@dont-email.me>
<lch1v6Fpo4eU5@mid.individual.net> <v3vk3k$26746$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net gS3aMiXiQ6rZE6A0MXmOaAGCmXs6NGJw4S80vm0+UJ2Q82mIl9
Cancel-Lock: sha1:LXlzGuidTNHvX0lO1B71QWewRwA= sha256:5gcCNZGs5JZDEO6pkUE9iNqgDEnpTV85yqMVPPRSBKg=
User-Agent: Mozilla Thunderbird
Content-Language: en-US, de-DE
In-Reply-To: <v3vk3k$26746$1@dont-email.me>
X-Antivirus: Avast (VPS 240607-8, 7.6.2024), Outbound message
X-Antivirus-Status: Clean
View all headers

(Common) LISP/SBCL

essential structure consists of two fields (or: one left hand field, and
one right hand field), which can extend trough other (same) fields of
the given field pair.

The lhs of the first form can be see as reference to it self or as start
point, that contain a pointer to the next form, which is represented on
the rhs.

You can cocoon this by other functions and/or commands/keywords, ...

=> here is an example: (1 2)
this is a simple form of a list, containing 1 and 2.

=> here is an example: (+ 2 1)
- this is a simple form of a operation,
- the + sign after the first paren is a "addition" function, that
take the first number from right (the 1) will be evaluate first,
and the add (+) symbol (which is a function) "signs" that the
next coming number (the 2) should be added to the (before eval 1)
so, you get as result the three (3).

=> each operation/command/task must have two objects, except, you call
a non-parameterized function or you build a list.

If you evaluate only one form, then you could be get a error message.
Or, if you evaluate a boolean value false (which is in LISP = nil) or
a boolean value true (wich is in LISP the single symbol T ).

You can create dictionaries by paring two elements or forms, where you
give a key on the left side, and a value on the right hand side:

(A . 1) or: (U . 3)

Jens

Subject: Re: Rather simple list/set operation [?]
From: Madhu
Newsgroups: comp.lang.lisp
Organization: Motzarella
Date: Sat, 8 Jun 2024 16:05 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Rather simple list/set operation [?]
Date: Sat, 08 Jun 2024 21:35:34 +0530
Organization: Motzarella
Lines: 55
Message-ID: <m35xuj773l.fsf@leonis4.robolove.meer.net>
References: <v3uefj$202pe$1@dont-email.me> <v3vi98$25sr1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 08 Jun 2024 18:05:36 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2c2f8524b902073f826827c89faf1dbb";
logging-data="2822141"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185zOJ9oH4lqyiGfMxXIhMopdtj+5LLXLk="
Cancel-Lock: sha1:TjAdvOoKJ1zJlOba+86UVxyAoLA=
sha1:KU4aofCJ5QswbHnizGEGXjm7JwE=
View all headers

* Jeff Barnett <v3vi98$25sr1$1@dont-email.me> :
Wrote on Fri, 7 Jun 2024 12:07:33 -0600:

> On 6/7/2024 1:56 AM, W J wrote:
>> From: Drew Krause
>> Subject: rather simple list/set operation
>> Date: Tue, 3 Jan 2012 19:01:19 -0600
>> Drew Krause wrote:
>>> Maybe someone can help me with this?
>>> I start with a list, e.g.
>>>
>>> ((0) (1 3) (1 2) (4 6) (5 7) (7 8))
>>>
>>>
>>> and want all members of intersecting lists to appear in the same sublist:
>>>
>>> => ((0) (1 2 3) (4 6) (5 7 8))

> I think the problem definition is ambiguous and not clarified by the
> example.
> Consider the following input lists:
> ((0 1) (1 2) (2 3)),
> ((0 1) (0 2) (0 3)).
> Any idea what Krause had in mind?

One way to answer this is to write a program and define the problem to
by what the program solves.

Here is a suitably cringeworthy function to do that in lisp.

(defun krause-group (list-of-lists &aux ret)
(dolist (list list-of-lists)
(assert (consp list))
(let ((cons (or (find-if (lambda (x) (find (car list) x)) ret)
(let ((cons (list (car list))))
(push cons ret)
cons))))
(dolist (elt (cdr list))
(unless (find elt cons)
(setf (cdr cons) (cons elt (cdr cons)))))))
(nreverse ret))

(krause-group '((0) (1 3) (1 2) (4 6) (5 7) (7 8)))
=> ((0) (1 2 3) (4 6) (5 8 7))

(krause-group '((0 1) (1 2) (2 3)))
(krause-group '((0 1) (0 2) (0 3)))

So obviously krause wanted both of these lists to produce 1 list
((0 3 2 1))

Subject: Re: Rather simple list/set operation [?]
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: novaBBS
Date: Sat, 8 Jun 2024 23:23 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: HenHanna@dev.null (HenHanna)
Newsgroups: comp.lang.lisp
Subject: Re: Rather simple list/set operation [?]
Date: Sat, 8 Jun 2024 23:23:02 +0000
Organization: novaBBS
Message-ID: <7c221443e88c02df44ab3b4716708ef9@www.novabbs.com>
References: <v3uefj$202pe$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="3610160"; mail-complaints-to="usenet@i2pn2.org";
posting-account="25PjXUQKTQXKZnoxTqVufZcfCkmLjnu8AjjfHtuMysE";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$sD9D90pZo48beIsPpdNA3.OjG51NmVCWVJaMxHdDSqFVaHl9WoGaa
X-Rslight-Posting-User: 5a1f1f09909a70d7ae18ae9af00e018f83ece577
X-Face: P#KeQ)CUdd!==@fw~Ms1=,Hb`IWtb6:Mw)x3B=H1BfNC\lz?Nb&)M9}$>?'X7l;CuB}utlJ=PHsRBSG6X>dYZ$[>P]$~+`>@V6$t}hTLoQ7XC~W\>:`B3ALU]SH;d(\MEc}znW8m}-ma&yPFkJ2@KSQrz=!Y;><;6a>z6N+mt`ClCt.PAE<o+B$qjwejZSZ,w]^;vrdl24z5(pm={l,F10qRDF
View all headers

B. Pym wrote:

> From: Drew Krause
> Subject: rather simple list/set operation
> Date: Tue, 3 Jan 2012 19:01:19 -0600

> Drew Krause wrote:

>> Maybe someone can help me with this?
>>
>> I start with a list, e.g. ((0) (1 3) (1 2) (4 6) (5 7) (7 8))
>>
>> and want all members of intersecting lists to appear in the same
>> sublist:
>> => ((0) (1 2 3) (4 6) (5 7 8))

> Gauche Scheme:

> (use srfi-1) ; "lset-" functions
> (use srfi-42) ; do-ec

> (define (coalesce lists)
> (define accum '())
> (do-ec (:list x lists)
> (receive
> (miss hit)
> (partition (lambda (y) (null? (lset-intersection equal? x y)))
> accum)
> (set! accum
> (cons (apply lset-union equal? x hit) miss))))
> accum)

> (coalesce '((2 4) (8 9) (4 5 8)))
> ===>
> ((2 9 4 5 8))

> (coalesce '((2 4) (3 9) (5 6) (2 3)))
> ===>
> ((4 9 2 3) (5 6))

> (coalesce '((0) (1 3) (1 2) (4 6) (5 7) (7 8)))
> ===>
> ((5 7 8) (4 6) (3 1 2) (0))

> (coalesce '((2 4) (3 9) (5 6) (2 3) (55 66) (0) (66 6)))
> ===>
> ((5 55 66 6) (0) (4 9 2 3))

Do-ec and Receive often go together?
Is there a set of programs (or Problems) or Tutorial for this style of
programming?

Transitive closure constructs the output graph from the
input graph.
In computer science, the concept of transitive closure can be thought of
as constructing a data structure that makes it possible to answer
reachability questions.

1

rocksolid light 0.9.8
clearnet tor