Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Free markets select for winning solutions." -- Eric S. Raymond


devel / comp.lang.scheme / Re: anaphoric lambda

SubjectAuthor
* anaphoric lambdaRobert L.
+- Re: anaphoric lambdaRobert L.
`- Re: anaphoric lambdaRobert L.

1
anaphoric lambda

<t01vhv$19e3$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!aioe.org!j3gMQKcTBPbPhesBtuDbWw.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.scheme
Subject: anaphoric lambda
Date: Sun, 6 Mar 2022 09:40:16 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t01vhv$19e3$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="42435"; posting-host="j3gMQKcTBPbPhesBtuDbWw.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 09:40 UTC

A limited anaphoric lambda implemented with syntax-rules.

Examples:

(append-map (& list u u) '(a b c d))
===>
(a a b b c c d d)

((& / v (+ u u)) 2 88)
===>
22

(map (& string-append u (symbol->string v))
'("foo" "back")
'(bar track))
===>
("foobar" "backtrack")

(for-each
(& print (string-append u "-" v "-" w))
'("tick" "nick")
'("tock" "knock")
'("tack" "knack"))
===>
tick-tock-tack
nick-knock-knack

I'm not a macro guru, so this can probably be improved.

(define-syntax &-aux
(syntax-rules (u v w quote)
[(_ whole shadow (param ...) () original)
(lambda (param ...) original)]
[(_ (u more ...) (x y ...) () ps original)
(&-aux (more ...) (y ...) (x) ps original)]
[(_ (v more ...) (x y ...) (a) ps original)
(&-aux (more ...) (y ...) (a x) ps original)]
[(_ (w more ...) (x y ...) (a b) ps original)
(&-aux (more ...) (y ...) (a b x) ps original)]
[(_ ((quote ...) more ...) (y z ...) params ps original)
(&-aux (more ...) (z ...) params ps original)]
[(_ ('x more ...) (y z ...) params ps original)
(&-aux (more ...) (z ...) params ps original)]
[(_ ((s ...) more ...) (y z ...) params ps original)
(&-aux (s ... more ...) (s ... z ...) params ps original)]
[(_ (x more ...) (y z ...) params ps original)
(&-aux (more ...) (z ...) params ps original)]
[(_ () shadow params (p ps ...) original)
(&-aux original original params (ps ...) original)]))

;; Lambda with anaphoric parameters u, v, and w.
(define-syntax &
(syntax-rules ()
[(& x ...)
(&-aux (x ...) (x ...) () (1 2 3) (x ...))]))

Re: anaphoric lambda

<t0jouu$885$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!aioe.org!tQVCr3s5BQliuntAiUVMWw.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.scheme
Subject: Re: anaphoric lambda
Date: Sun, 13 Mar 2022 03:38:09 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t0jouu$885$1@gioia.aioe.org>
References: <t01vhv$19e3$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="8453"; posting-host="tQVCr3s5BQliuntAiUVMWw.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, 13 Mar 2022 03:38 UTC

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

> A limited anaphoric lambda implemented with syntax-rules.
>
> Examples:
>
> (append-map (& list u u) '(a b c d))
> ===>
> (a a b b c c d d)
>
>
> ((& / v (+ u u)) 2 88)
> ===>
> 22
>
>
> (map (& string-append u (symbol->string v))
> '("foo" "back")
> '(bar track))
> ===>
> ("foobar" "backtrack")
>
>
> (for-each
> (& print (string-append u "-" v "-" w))
> '("tick" "nick")
> '("tock" "knock")
> '("tack" "knack"))
> ===>
> tick-tock-tack
> nick-knock-knack

Somewhat shorter and simpler:

(define-syntax &-aux
(syntax-rules (u v w quote)
[(_ () shadow (param ...) original)
(lambda (param ...) original)]
[(_ (u more ...) (x y ...) () original)
(&-aux original original (x) original)]
[(_ (v more ...) (x y ...) (a) original)
(&-aux original original (a x) original)]
[(_ (w more ...) (x y ...) (a b) original)
(&-aux () () (a b x) original)]
[(_ ((quote ...) more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]
[(_ ('x more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]
[(_ ((s ...) more ...) (y z ...) params original)
(&-aux (s ... more ...) (s ... z ...) params original)]
[(_ (x more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]))

;; Lambda with anaphoric parameters u, v, and w.
(define-syntax &
(syntax-rules ()
[(& x ...)
(&-aux (x ...) (x ...) () (x ...))]))

Re: anaphoric lambda

<t1h817$18up$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!aioe.org!9vX9WqADbcG1VgJGr1/H5Q.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.scheme
Subject: Re: anaphoric lambda
Date: Thu, 24 Mar 2022 07:53:14 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t1h817$18up$1@gioia.aioe.org>
References: <t01vhv$19e3$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="41945"; posting-host="9vX9WqADbcG1VgJGr1/H5Q.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. - Thu, 24 Mar 2022 07:53 UTC

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

> A limited anaphoric lambda implemented with syntax-rules.
>
> Examples:
>
> (append-map (& list u u) '(a b c d))
> ===>
> (a a b b c c d d)
>
>
> ((& / v (+ u u)) 2 88)
> ===>
> 22
>
>
> (map (& string-append u (symbol->string v))
> '("foo" "back")
> '(bar track))
> ===>
> ("foobar" "backtrack")
>
>
> (for-each
> (& print (string-append u "-" v "-" w))
> '("tick" "nick")
> '("tock" "knock")
> '("tack" "knack"))
> ===>
> tick-tock-tack
> nick-knock-knack
>
>
> I'm not a macro guru, so this can probably be improved.
>
>
> (define-syntax &-aux
> (syntax-rules (u v w quote)
> [(_ whole shadow (param ...) () original)
> (lambda (param ...) original)]
> [(_ (u more ...) (x y ...) () ps original)
> (&-aux (more ...) (y ...) (x) ps original)]
> [(_ (v more ...) (x y ...) (a) ps original)
> (&-aux (more ...) (y ...) (a x) ps original)]
> [(_ (w more ...) (x y ...) (a b) ps original)
> (&-aux (more ...) (y ...) (a b x) ps original)]
> [(_ ((quote ...) more ...) (y z ...) params ps original)
> (&-aux (more ...) (z ...) params ps original)]
> [(_ ('x more ...) (y z ...) params ps original)
> (&-aux (more ...) (z ...) params ps original)]
> [(_ ((s ...) more ...) (y z ...) params ps original)
> (&-aux (s ... more ...) (s ... z ...) params ps original)]
> [(_ (x more ...) (y z ...) params ps original)
> (&-aux (more ...) (z ...) params ps original)]
> [(_ () shadow params (p ps ...) original)
> (&-aux original original params (ps ...) original)]))
>
> ;; Lambda with anaphoric parameters u, v, and w.
> (define-syntax &
> (syntax-rules ()
> [(& x ...)
> (&-aux (x ...) (x ...) () (1 2 3) (x ...))]))

(define-syntax &-aux
(syntax-rules (u v w & lambda quote)
[(_ () shadow (param ...) original)
(lambda (param ...) original)]
[(_ (u more ...) (x y ...) () original)
(&-aux original original (x) original)]
[(_ (v more ...) (x y ...) (a) original)
(&-aux original original (a x) original)]
[(_ (w more ...) (x y ...) (a b) original)
(&-aux () () (a b x) original)]
[(_ ((lambda x ...) more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]
[(_ ((& x ...) more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]
[(_ ((quote x ...) more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]
[(_ ('x more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]
[(_ ((s ...) more ...) (y z ...) params original)
(&-aux (s ... more ...) (s ... z ...) params original)]
[(_ (x more ...) (y z ...) params original)
(&-aux (more ...) (z ...) params original)]))
;; Lambda with anaphoric parameters u, v, and w.
(define-syntax &
(syntax-rules ()
[(& x ...)
(&-aux (x ...) (x ...) () (x ...))]))

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor