Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"It's like deja vu all over again." -- Yogi Berra


devel / comp.lang.scheme / Clojure threading in scheme.

SubjectAuthor
* Clojure threading in scheme.Alain De Vos
`- Re: Clojure threading in scheme.Chris Vine

1
Clojure threading in scheme.

<1e46b7e6-d47a-4a17-8bf2-5da5fde9b93fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=99&group=comp.lang.scheme#99

  copy link   Newsgroups: comp.lang.scheme
X-Received: by 2002:a0c:f9cc:: with SMTP id j12mr23185040qvo.2.1636824028846;
Sat, 13 Nov 2021 09:20:28 -0800 (PST)
X-Received: by 2002:a25:d4c4:: with SMTP id m187mr28698741ybf.47.1636824028688;
Sat, 13 Nov 2021 09:20:28 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.scheme
Date: Sat, 13 Nov 2021 09:20:28 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=81.244.27.203; posting-account=kTRirAoAAACnF_wtAOSamxYBSVvmJuCa
NNTP-Posting-Host: 81.244.27.203
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e46b7e6-d47a-4a17-8bf2-5da5fde9b93fn@googlegroups.com>
Subject: Clojure threading in scheme.
From: devosalain71@gmail.com (Alain De Vos)
Injection-Date: Sat, 13 Nov 2021 17:20:28 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Alain De Vos - Sat, 13 Nov 2021 17:20 UTC

Clojure has a syntax for left to right evaluation and pipeline.
https://clojure.org/guides/threading_macros
Does there exist a similar function in scheme ?
Or a similar function in scheme with a name be coded in a few lines of code.
I think you apply on the expression left and that output is then the input of
the expression on the right etc...
It allows to read nested expressions from left to right which is more like the natural language.

I have found rackjure but this is only an implementation of racket.
It would be nice to do something similar in chez-scheme

Re: Clojure threading in scheme.

<20211113175650.4291b85ef30e8840a17757ae@cvine--nospam--.freeserve.co.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=100&group=comp.lang.scheme#100

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!aioe.org!4ZvN0UF/4MluBDwxl2H0CA.user.46.165.242.75.POSTED!not-for-mail
From: chris@cvine--nospam--.freeserve.co.uk (Chris Vine)
Newsgroups: comp.lang.scheme
Subject: Re: Clojure threading in scheme.
Date: Sat, 13 Nov 2021 17:56:50 +0000
Organization: Aioe.org NNTP Server
Message-ID: <20211113175650.4291b85ef30e8840a17757ae@cvine--nospam--.freeserve.co.uk>
References: <1e46b7e6-d47a-4a17-8bf2-5da5fde9b93fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="26429"; posting-host="4ZvN0UF/4MluBDwxl2H0CA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu)
 by: Chris Vine - Sat, 13 Nov 2021 17:56 UTC

On Sat, 13 Nov 2021 09:20:28 -0800 (PST)
Alain De Vos <devosalain71@gmail.com> wrote:
> Clojure has a syntax for left to right evaluation and pipeline.
> https://clojure.org/guides/threading_macros
> Does there exist a similar function in scheme ?
> Or a similar function in scheme with a name be coded in a few lines of code.
> I think you apply on the expression left and that output is then the input of
> the expression on the right etc...
> It allows to read nested expressions from left to right which is more like the natural language.
>
> I have found rackjure but this is only an implementation of racket.
> It would be nice to do something similar in chez-scheme

I don't know clojure but it is relatively simple to make your own
pipeline macro, if that is what you are after. Here's one approach:

(define-syntax ->
(lambda (x)
(syntax-case x ()
[(_ exp0 exp1 ...)
(let ([reversed (reverse #'(exp0 exp1 ...))])
(with-syntax
([out
(let loop ([first (car reversed)]
[rest (cdr reversed)])
(if (null? rest)
first
(syntax-case first ()
[(func arg0 ...)
(append #'(func arg0 ...)
(list (loop (car rest) (cdr rest))))])))])
#'out))])))

You can also do it with syntax-rules:

(define-syntax ->
(syntax-rules ()
[(-> exp)
exp]
[(-> exp ... (op args ...))
(op args ... (-> exp ...))]))

Expressions are evaluated left to right, rather like ML's |>
operator. So usage of these is thus:

(-> "hello"
(format #t "~A~%"))

In that example the pipeline expression itself evaluated to
undefined (the return value of format), but it could evaluate to
anything.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor