Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #132: SCSI Chain overterminated


comp / comp.lang.scheme / Re: Simple problem in PG's ANSI Common Lisp

SubjectAuthor
* Re: Simple problem in PG's ANSI Common LispB. Pym
`- Re: Simple problem in PG's ANSI Common LispKaz Kylheku

1
Subject: Re: Simple problem in PG's ANSI Common Lisp
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 26 Sep 2024 02:17 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Simple problem in PG's ANSI Common Lisp
Date: Thu, 26 Sep 2024 02:17:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <vd2g7l$1ae1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 26 Sep 2024 04:17:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2b7f8b0e9338bb313cc30be8fc596d5b";
logging-data="43457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DqSUveh5+c9pQUFjM1J6e"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:QvmPpmgXl9XbMguldmpl51uF8rI=
View all headers

paul graham wrote:

> Or you could write
>
> (defun pos+ (lst)
> (let ((i -1))
> (mapcar #'(lambda (x) (+ x (incf i)))
> lst)))
>
> Btw, in Arc that would be
>
> (def pos+ (lst)
> (let i -1
> (map [+ _ (++ i)] lst)))

Gauche Scheme

(define (pos+ lst)
(let1 i -1
(map (~> (+ (inc! i))) lst)))

Given:

(define-syntax ->
(syntax-rules ()
[(_ x) x]
[(_ x (y more ...) z ...)
(-> (y x more ...) z ...)]
[(_ x y z ...)
(-> (y x) z ...)]))

(define-syntax ~>
(syntax-rules ()
[(_ (func0 a ...) func ...)
(lambda xs (-> (apply func0 (append xs (list a ...))) func ...))]
[(_ func0 func ...)
(lambda xs (-> (apply func0 xs) func ...))]))

Subject: Re: Simple problem in PG's ANSI Common Lisp
From: Kaz Kylheku
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 26 Sep 2024 03:56 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Simple problem in PG's ANSI Common Lisp
Date: Thu, 26 Sep 2024 03:56:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <20240925205452.294@kylheku.com>
References: <vd2g7l$1ae1$1@dont-email.me>
Injection-Date: Thu, 26 Sep 2024 05:56:44 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6301191434da988399c4b082ba0fe62f";
logging-data="63654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189sxfHxPEC1mNKvRhNAw+JTvyfESewMKk="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:n8PDcT9BUQMsw9fJhaPhPOL8c1c=
View all headers

On 2024-09-26, B. Pym <Nobody447095@here-nor-there.org> wrote:
> paul graham wrote:
>
>> Or you could write
>>
>> (defun pos+ (lst)
>> (let ((i -1))
>> (mapcar #'(lambda (x) (+ x (incf i)))
>> lst)))
>>
>> Btw, in Arc that would be
>>
>> (def pos+ (lst)
>> (let i -1
>> (map [+ _ (++ i)] lst)))
>
>
> Gauche Scheme
>
> (define (pos+ lst)
> (let1 i -1
> (map (~> (+ (inc! i))) lst)))
>
> Given:
>
> (define-syntax ->
> (syntax-rules ()
> [(_ x) x]
> [(_ x (y more ...) z ...)
> (-> (y x more ...) z ...)]
> [(_ x y z ...)
> (-> (y x) z ...)]))
>
> (define-syntax ~>
> (syntax-rules ()
> [(_ (func0 a ...) func ...)
> (lambda xs (-> (apply func0 (append xs (list a ...))) func ...))]
> [(_ func0 func ...)
> (lambda xs (-> (apply func0 xs) func ...))]))

TXR Lisp:

1> [mapcar + '(10 20 30) 0]
(10 21 32)

Given: TMF language, and that's it.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

1

rocksolid light 0.9.8
clearnet tor