Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Linux is obsolete -- Andrew Tanenbaum


devel / comp.lang.forth / predicate-collect

SubjectAuthor
* predicate-collectRobert L.
+- Re: predicate-collectRobert L.
+- Re: predicate-collectHans Bezemer
+- Re: predicate-collectJali Heinonen
`- Re: predicate-collectKerr-Mudd, John

1
predicate-collect

<t0fc0r$1a7i$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!aict7WByTLRqCofWwrAtQQ.user.46.165.242.75.POSTED!not-for-mail
From: No_spamm...@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.forth
Subject: predicate-collect
Date: Fri, 11 Mar 2022 11:32:44 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t0fc0r$1a7i$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="43250"; posting-host="aict7WByTLRqCofWwrAtQQ.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. - Fri, 11 Mar 2022 11:32 UTC

Write a function that accepts a list and some predicates
(functions that return either true or false).
The function must subdivide the list;
the first sublist must contain the elements that satisfy
the first predicate; the second sublist must have the
elements that satisfy the second predicate; and so on.
The last sublist will contain the elements that satisfied
none of the predicates.

Gauche Scheme or Racket:

(define (predicate-collect items . preds)
(if (null? preds)
(list items)
(let-values (((yes no) (partition (car preds) items)))
(cons yes (apply predicate-collect no (cdr preds))))))

(predicate-collect
'(-5 -4 -3 -2 -1 0 1 2 3 4 5)
even?
(lambda (n) (< n 0))
(lambda (n) (> n 3)))

===>
((-4 -2 0 2 4) (-5 -3 -1) (5) (1 3))

In Forth?

Re: predicate-collect

<t0fci9$1ijk$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!anMPK3uCSZpgHtYE5E+I6g.user.46.165.242.75.POSTED!not-for-mail
From: No_spamm...@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.forth
Subject: Re: predicate-collect
Date: Fri, 11 Mar 2022 11:42:01 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t0fci9$1ijk$1@gioia.aioe.org>
References: <t0fc0r$1a7i$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="51828"; posting-host="anMPK3uCSZpgHtYE5E+I6g.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. - Fri, 11 Mar 2022 11:42 UTC

On 3/11/2022, Robert L. wrote:

> the first sublist must contain the elements that satisfy
> the first predicate; the second sublist must have the
> elements that satisfy the second predicate; and so on.

Correction:

Elements that are put in a sublist are not available
for subsequent sublists.

Re: predicate-collect

<36784351-2052-4072-9621-0cd8aa842909n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:45d8:0:b0:62c:e5a5:34cf with SMTP id s207-20020a3745d8000000b0062ce5a534cfmr6327456qka.367.1647003755868;
Fri, 11 Mar 2022 05:02:35 -0800 (PST)
X-Received: by 2002:ac8:7fd0:0:b0:2e1:b8e3:abfd with SMTP id
b16-20020ac87fd0000000b002e1b8e3abfdmr4221244qtk.508.1647003755618; Fri, 11
Mar 2022 05:02:35 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 11 Mar 2022 05:02:35 -0800 (PST)
In-Reply-To: <t0fc0r$1a7i$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <t0fc0r$1a7i$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <36784351-2052-4072-9621-0cd8aa842909n@googlegroups.com>
Subject: Re: predicate-collect
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Fri, 11 Mar 2022 13:02:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1395
 by: Hans Bezemer - Fri, 11 Mar 2022 13:02 UTC

On Friday, March 11, 2022 at 12:32:46 PM UTC+1, Robert L. wrote:
> In Forth?

Hey, our favorite incel is back! Create this one in Scheme. And do something useful with your life: https://en.wikipedia.org/wiki/Damm_algorithm

Hans Bezemer

Re: predicate-collect

<1f98974f-ad8a-485a-818a-ed73feed187cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:1434:b0:67d:40a2:da33 with SMTP id k20-20020a05620a143400b0067d40a2da33mr6939841qkj.93.1647015291739;
Fri, 11 Mar 2022 08:14:51 -0800 (PST)
X-Received: by 2002:a05:622a:1906:b0:2e0:77a7:16c4 with SMTP id
w6-20020a05622a190600b002e077a716c4mr9007542qtc.119.1647015291465; Fri, 11
Mar 2022 08:14:51 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!border1.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: Fri, 11 Mar 2022 08:14:51 -0800 (PST)
In-Reply-To: <t0fc0r$1a7i$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=87.95.20.28; posting-account=kiOBZQoAAADFsAs31ZHaefxTuQxv84Wm
NNTP-Posting-Host: 87.95.20.28
References: <t0fc0r$1a7i$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1f98974f-ad8a-485a-818a-ed73feed187cn@googlegroups.com>
Subject: Re: predicate-collect
From: jali.hei...@gmail.com (Jali Heinonen)
Injection-Date: Fri, 11 Mar 2022 16:14:51 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 49
 by: Jali Heinonen - Fri, 11 Mar 2022 16:14 UTC

perjantai 11. maaliskuuta 2022 klo 13.32.46 UTC+2 Robert L. kirjoitti:
> Write a function that accepts a list and some predicates
> (functions that return either true or false).
> The function must subdivide the list;
> the first sublist must contain the elements that satisfy
> the first predicate; the second sublist must have the
> elements that satisfy the second predicate; and so on.
> The last sublist will contain the elements that satisfied
> none of the predicates.
>
> Gauche Scheme or Racket:
>
> (define (predicate-collect items . preds)
> (if (null? preds)
> (list items)
> (let-values (((yes no) (partition (car preds) items)))
> (cons yes (apply predicate-collect no (cdr preds))))))
>
> (predicate-collect
> '(-5 -4 -3 -2 -1 0 1 2 3 4 5)
> even?
> (lambda (n) (< n 0))
> (lambda (n) (> n 3)))
>
> ===>
> ((-4 -2 0 2 4) (-5 -3 -1) (5) (1 3))
>
>
> In Forth?

8th:

: collect \ a a -- a
a:shift null? not if
a:new >r
_swap ( nip w:exec ) curry a:/ r@ swap a:push drop
swap ( ( w:exec nip ) curry a:/ r@ swap a:push drop ) a:each! drop
r> swap a:len if
a:push
else
drop
then
else
2drop
then ;

: app:main
[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
[ ( 2 n:mod ) , ( 0 n:< ) , ( 3 n:> ) ]
collect . cr ;

Re: predicate-collect

<20220312143204.ebafc81ea9dd25432c026451@127.0.0.1>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: adm...@127.0.0.1 (Kerr-Mudd, John)
Newsgroups: comp.lang.forth
Subject: Re: predicate-collect
Date: Sat, 12 Mar 2022 14:32:04 +0000
Organization: Dis
Lines: 17
Message-ID: <20220312143204.ebafc81ea9dd25432c026451@127.0.0.1>
References: <t0fc0r$1a7i$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="8a4e4032b71fed404e486b600e236aa8";
logging-data="28582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19w/T+xWwg/bB6sygqXWD8RIZcDjU1Kaik="
Cancel-Lock: sha1:GbJqx5J5sqhVJaLv5qgI8XTyByE=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
;X-no-Archive: Maybe
GNU: Terry Pratchett
 by: Kerr-Mudd, John - Sat, 12 Mar 2022 14:32 UTC

On Fri, 11 Mar 2022 11:32:44 -0000 (UTC)
"Robert L." <No_spamming@noWhere_7073.org> wrote:

> Write a function that accepts a list and some predicates
[]
>
> Gauche Scheme or Racket:
>
[]
>
>
> In Forth?

Hi Gavino! Long time no see!

--
Bah, and indeed Humbug.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor