eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ConsStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ConsStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--ConsStream

Package:
stx:libbasic2
Category:
Collections-Linked
Version:
rev: 1.4 date: 2011/09/27 09:42:44
user: cg
file: ConsStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger (Dec 2003)

Description:


A stream on a list (of conses)
Conses are not heavily used by Smalltalk (actually: not at all).
Consider this a demo class.


Related information:



Class protocol:

instance creation
o  on: aCons


Instance protocol:

accessing
o  list: something

reading
o  atEnd

o  next


Examples:


    |list s|

    list := Cons fromArray:#(1 2 3 4).   
    s := list readStream.
    [s atEnd] whileFalse:[
        Transcript showCR:(s next).
    ].
    |gen allNumbers s|

    gen := [:n | LazyCons car:n cdr:[ gen value:n+1 ]].
    allNumbers := gen value:1.

    s := allNumbers readStream.
    100 timesRepeat:[
        Transcript showCR:(s next).
    ].


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 19 Mar 2024 02:11:32 GMT