Re: Simple problem in PG's ANSI Common Lisp

Liste des GroupesRevenir à cl scheme 
Sujet : Re: Simple problem in PG's ANSI Common Lisp
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.scheme
Date : 26. Sep 2024, 03:17:26
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vd2g7l$1ae1$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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 ...))]))

Date Sujet#  Auteur
26 Sep 24 * Re: Simple problem in PG's ANSI Common Lisp2B. Pym
26 Sep 24 `- Re: Simple problem in PG's ANSI Common Lisp1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal