eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'GeometricSeries':

Home

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

Class: GeometricSeries


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ReadOnlySequenceableCollection
            |
            +--GeometricSeries

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.3 date: 2017/07/05 08:47:39
user: cg
file: GeometricSeries.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


Much like intervals (which have a constant difference between elements), 
these have a constant factor between them.
GeometricSeries represent a collection (or range) of values specified by
a startValue, an endValue and a *factor*. 
Like with intervals, the elements are computed, not stored.
For example, 
    the GeometricSeries (1 to:100 byFactor:2) contains the elements (1 2 4 8 16 32 64).
    and GeometricSeries (1 to:(1/100) byFactor:(1/2)) contains the elements (1 1/2 1/4 1/8 1/16 1/32 1/64).

examples:

    (1 to:100 byFactor:2) do:[:i | Transcript showCR:i]
    (1 to:100 byFactor:1.1) do:[:i | Transcript showCR:i]
    (1 to:100 byFactor:2) asArray  
    (1 to:128 byFactor:2) asArray  
    (128 to:2 byFactor:(1/2)) asArray  

    (1 to:128 byFactor:2) sum
    (1 to:128 byFactor:2) asArray sum    
    


Class protocol:

instance creation
o  from: start to: stop byFactor: factor
return a new geometric series with elements from start
to stop by a factor


Instance protocol:

enumerating
o  do: aBlock
evaluate the argument, aBlock for every element in the receiver.
Redefined since SeqColl accesses the receiver with at:,
which is slow for intervals.
usage example(s):
     (1 to:128 byFactor:2) do:[:v | Transcript showCR:v]
     (16 to:1 byFactor:(1/2)) do:[:v | Transcript showCR:v]
     (1.0 to:128.0 byFactor:2) do:[:v | Transcript showCR:v]

     (GeometricSeries from:1 to:128 byFactor:2) do:[:v | Transcript showCR:v]

o  size
(comment from inherited method)
return the number of elements in the collection.
concrete implementations must define this

printing & storing
o  printOn: aStream
append a printed representation to aStream

o  storeOn: aStream
store a representation which can reconstruct the receiver to aStream

private
o  setFrom: startVal to: stopVal byFactor: factorVal
set start, stop and factor components

o  species
return the type of collection to be returned by collect, select etc.



ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 19 Sep 2018 11:28:23 GMT