Problem using cons-stream 
Author Message
 Problem using cons-stream

Hi,

I have been using a version of scheme downloaded from Rice University:
PLT/packages/drscheme....(drscheme version 100) and am running the
majority of my programs with mzscheme.

According to SICP, cons-stream is supposed to be a special form;
however, it is not working this way on the version I have downloaded.
Any suggestions? Am I doing something wrong, or do I need a different
version to use stream functions?

Thanks,  Cheryl



Fri, 17 May 2002 03:00:00 GMT  
 Problem using cons-stream

Quote:

> Hi,

> I have been using a version of scheme downloaded from Rice University:
> PLT/packages/drscheme....(drscheme version 100) and am running the
> majority of my programs with mzscheme.

> According to SICP, cons-stream is supposed to be a special form;
> however, it is not working this way on the version I have downloaded.
> Any suggestions? Am I doing something wrong, or do I need a different
> version to use stream functions?

> Thanks,  Cheryl

cons-stream isn't part of R5RS scheme; I have a file starting:

(define (sicp:memo-proc proc)
  (let ((already-run? #f)
        (result #f))
    (lambda ()
      (if (not already-run?)
          (begin (set! result (proc))
                 (set! already-run? #t)
                 result)
          result))))

(define-macro sicp:delay (lambda (exp) `(sicp:memo-proc (lambda () ,exp))))
(define (sicp:force delayed-object) (delayed-object))
(define-macro cons-stream (lambda (a b) `(cons ,a (sicp:delay ,b))))

(define (stream-car stream) (car stream))
(define (stream-cdr stream) (sicp:force (cdr stream)))
(define (stream-null? stream) (null? stream))

which should be enough to get you going.

Have fun!

Michael



Sat, 18 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. xscheme, cons-stream, macros

2. cons-stream definition

3. MAT CON and MAT CON(expr)

4. Leer hoja excel con sql y odbc con NetExp3.1

5. Pros/Cons of using VA ReportWriter over Crystal Reports

6. Q: Leonardo , any pros/cons using this ?

7. Using a cons to hold a list's head and tail

8. Problemi con la funzione fread() - Problems with fread() function

9. problems con encoder

10. Optimising Browse Load with Buffering using STREAM and FLUSH

11. Using STREAM

12. Q: Acquiring data using two E series devices connected by RTSI and streaming data to disk

 

 
Powered by phpBB® Forum Software