| Deutsch English Français Italiano |
|
<vd2g7l$1ae1$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <Nobody447095@here-nor-there.org>
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=
Bytes: 1680
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 ...))]))