[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SICP stream question
From: |
Keith Wright |
Subject: |
Re: SICP stream question |
Date: |
Fri, 27 Apr 2001 13:52:11 -0400 |
> Cc: address@hidden
>
> Is define-macro portable across the various scheme implementations?
No.
> The only thing I could find in r5rs was define-syntax, which I
> couldn't get to work.
This works for me
file scheme-test:
; orignal definition
; (define cons-stream
; (procedure->macro
; (lambda (x env) `(cons ,(cadr x) (delay ,(caddr x))))))
(use-modules (ice-9 syncase))
(define-syntax cons-stream
(syntax-rules ()
((_ head tail) (cons head (delay tail))) ))
<All the functions you wrote>
guile> (load "scheme-test.scm")
guile> (map (lambda (n) (stream-ref primes n)) '(0 1 2 3 4 5 12))
(2 3 5 7 11 13 41)
--
-- Keith Wright <address@hidden>
Programmer in Chief, Free Computer Shop <http://www.free-comp-shop.com>
--- Food, Shelter, Source code. ---