cooooookie monster
cooooookie monster

Reputation: 334

Building an infinite stream in dr.Racket overloads my memory limit?

For an Assignment im building my own Stream Implementation in Dr.Racket, i think i have it all done correctly...

however now im trying to implicitly define some infinite streams to work with for testing everything

(define ones (stream-cons 1 ones))

-i have created my own implementation of cons-stream, and i don't believe that is the issue here the issue is when i try and run this code i get an error saying

ones: undefined;
reference an identifier before its definition

what am i doing wrong? if i was to say create a procedure like

(define (ones) (stream-cons 1 ones))

i am the definition is allowed but the implementation would need to change a little

Upvotes: 0

Views: 533

Answers (1)

ben rudgers
ben rudgers

Reputation: 3669

The correct call to ones is (stream-first ones).

See the Racket documentation: http://docs.racket-lang.org/reference/streams.html

Upvotes: 2

Related Questions