Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You have a message from the operator.


devel / comp.lang.forth / Consolidation

SubjectAuthor
* ConsolidationRobert L.
`- Re: ConsolidationS Jack

1
Consolidation

<t03a58$e51$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=17044&group=comp.lang.forth#17044

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!47RQ64UTjUh2iI387N5j1g.user.46.165.242.75.POSTED!not-for-mail
From: No_spamm...@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.forth
Subject: Consolidation
Date: Sun, 6 Mar 2022 21:47:21 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t03a58$e51$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="14497"; posting-host="47RQ64UTjUh2iI387N5j1g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Sun, 6 Mar 2022 21:47 UTC

You have an association list with pairs like this:

((key value) ...)

In the list there are some keys that occur more
than once. Create a modified list in which
each key is found only once (with all of of its
values appended).

Gauche Scheme and Racket:

;; Racket needs this SRFI:
(require srfi/1) ;; alist-delete fold

(define (amerge kv a)
(let ((found (assoc (car kv) a)))
(if found
(cons (append found (cdr kv))
(alist-delete (car kv) a))
(cons kv a))))

(define (consolidate-alist pairs)
(fold amerge '() pairs))

(consolidate-alist
'((bob 2) (bill 3) (ed 9) (bob 4) (xs 0) (bill 5)
(dc 99) (bob 6) (ed 8)))

===>
((ed 9 8) (bob 2 4 6) (dc 99) (bill 3 5) (xs 0))

In Forth?

Re: Consolidation

<69579997-2a21-4191-bca3-1a9e7cacfb7cn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=17053&group=comp.lang.forth#17053

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2a06:b0:67a:f44c:b9ad with SMTP id o6-20020a05620a2a0600b0067af44cb9admr4797921qkp.458.1646624411031;
Sun, 06 Mar 2022 19:40:11 -0800 (PST)
X-Received: by 2002:a05:6214:d82:b0:435:7070:a669 with SMTP id
e2-20020a0562140d8200b004357070a669mr6030885qve.130.1646624410830; Sun, 06
Mar 2022 19:40:10 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 6 Mar 2022 19:40:10 -0800 (PST)
In-Reply-To: <t03a58$e51$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:217a:80c4:9224:81d6;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:217a:80c4:9224:81d6
References: <t03a58$e51$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <69579997-2a21-4191-bca3-1a9e7cacfb7cn@googlegroups.com>
Subject: Re: Consolidation
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Mon, 07 Mar 2022 03:40:11 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 67
 by: S Jack - Mon, 7 Mar 2022 03:40 UTC

On Sunday, March 6, 2022 at 3:47:26 PM UTC-6, Robert L. wrote:
> You have an association list with pairs like this:
>
> ((key value) ...)
>
> In the list there are some keys that occur more
> than once. Create a modified list in which
> each key is found only once (with all of of its
> values appended).
>
> Gauche Scheme and Racket:
>
> ;; Racket needs this SRFI:
> (require srfi/1) ;; alist-delete fold
>
> (define (amerge kv a)
> (let ((found (assoc (car kv) a)))
> (if found
> (cons (append found (cdr kv))
> (alist-delete (car kv) a))
> (cons kv a))))
>
> (define (consolidate-alist pairs)
> (fold amerge '() pairs))
>
>
> (consolidate-alist
> '((bob 2) (bill 3) (ed 9) (bob 4) (xs 0) (bill 5)
> (dc 99) (bob 6) (ed 8)))
>
> ===>
> ((ed 9 8) (bob 2 4 6) (dc 99) (bill 3 5) (xs 0))
>
>
>
> In Forth?
:) frogd
ELF32X86_64 Frog Version 1.0d

"job" /go
"bob 2" "bill 3" "ed 9" "bob 4" "xs 0" "bill 5" "dc 99" "bob 6" "ed 8" {
'echo "' mpad sas
begin depth 1 > while swap s+ "\n" s+ repeat
'"|sort' s+
/sys:send
} run1
{ pad 32 erase
2dup + >R
begin over r < while
\n split 2dup
bl split 2dup pad gscmp
if ( new item )
pad gts 2drop
cr type space
ii ( another of the same )
2drop type space
2drop
fi
repeat rdrop
} is hr:rrx
hr:rrx
bill 3 5
bob 2 4 6
dc 99
ed 8 9
xs 0
--
me

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor