Re: Can a macro define a macro?

Liste des GroupesRevenir à cl lisp 
Sujet : Re: Can a macro define a macro?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 18. Jun 2025, 11:29:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <102u4dg$32oas$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Pascal Costanza wrote:

For example, why don't you just write this?
 
(defun powersn (x n)
   (loop for i from to n collecting (expt x i)))


Rejected by SBCL:

; in: LAMBDA NIL
;     (LOOP FOR I FROM TO N
;           COLLECTING (EXPT X I))
;
; caught ERROR:
;   (in macroexpansion of (LOOP FOR I ...))
;   (hint: For more precise location, try *BREAK-ON-SIGNALS*.)
;   unknown LOOP keyword: N
;   current LOOP context: N COLLECTING.

Gauche Scheme.

(define (powersn x n)
  (map (cut  expt x <>) (liota n 1)))


(powersn 3 5)
  ===>
(3 9 27 81 243)

Date Sujet#  Auteur
18 Jun 25 o Re: Can a macro define a macro?1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal