eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'RecursiveSeriesStream':

Home

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

Class: RecursiveSeriesStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--PeekableStream
         |
         +--IteratorStream
            |
            +--RecursiveSeriesStream

Package:
stx:libbasic2
Category:
Streams
Version:
rev: 1.4 date: 2019/11/19 14:23:27
user: cg
file: RecursiveSeriesStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


documentation to be added.

class:
    <a short class summary here, describing what instances represent>

responsibilities:    
    <describing what my main role is>

collaborators:    
    <describing with whom and how I talk to>

API:
    <public api and main messages>
    
example:
    <a one-line examples on how to use - can also be in a separate example method>

implementation:
    <implementation points>


[instance variables:]

[class variables:]

example

|collatz| collatz := [:n | RecursiveSeriesStream on:[:n | n even ifTrue:[n/2] ifFalse:[n*3+1]] startValue:n]. (collatz[20]) next:20. (collatz[24]) next:20. (collatz[25]) next:30.

example2

|max bits collatz newNums| newNums := OrderedCollection new. bits := SortedCollection new. max := 2. collatz := RecursiveSeriesStream on:[:n | n even ifTrue:[n/2] ifFalse:[(n*3+1)/2]] startValue:1. 1 to:100000 do:[:n0 | newNums removeAll. collatz startValue:n0. [ |n| n := collatz next. newNums add:n. n <= max ] whileFalse. bits addAll:newNums. [bits notEmpty and:[bits first <= (max+1)]] whileTrue:[max := max max:(bits first). bits removeFirst]. ]. self halt.

Class protocol:

instance creation
o  on: aBlock startValue: startValue


Instance protocol:

accessing
o  atEnd

o  endValue: something
define a stop value

o  iterator: aOneArgBlock startValue: startValue

o  startValue: startValue

reading
o  next
return the next element from the stream by evaluating the nextBlock



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 23 Nov 2024 07:55:53 GMT