Interval.st
changeset 11409 82874ed12ab4
parent 11270 a616ba9b7f81
child 11477 2a46e08433d3
equal deleted inserted replaced
11408:3c3b1861c6fd 11409:82874ed12ab4
    37 documentation
    37 documentation
    38 "
    38 "
    39     Intervals represent a collection (or range) of numeric values specified by
    39     Intervals represent a collection (or range) of numeric values specified by
    40     a startValue, an endValue and a step. 
    40     a startValue, an endValue and a step. 
    41     The interesting thing is that the elements are computed, not stored.
    41     The interesting thing is that the elements are computed, not stored.
       
    42     However, protocol-wise, intervals behave like any other (read-only) sequenceable collection.
       
    43 
    42     For example, the interval (1 to:5) containes the elements (1 2 3 4 5) and
    44     For example, the interval (1 to:5) containes the elements (1 2 3 4 5) and
    43     (1 to:6 by:2) contains (1 3 5).
    45     (1 to:6 by:2) contains (1 3 5).
    44 
    46 
    45     examples:
    47     examples:
    46 
    48 
    64 ! !
    66 ! !
    65 
    67 
    66 !Interval class methodsFor:'instance creation'!
    68 !Interval class methodsFor:'instance creation'!
    67 
    69 
    68 from:start to:stop
    70 from:start to:stop
    69     "return a new interval with elements from start
    71     "return a new interval with elements from start to stop by 1"
    70      to stop by 1"
       
    71 
    72 
    72     ^ self new setFrom:start to:stop by:1
    73     ^ self new setFrom:start to:stop by:1
    73 !
    74 !
    74 
    75 
    75 from:start to:stop by:step
    76 from:start to:stop by:step
    76     "return a new interval with elements from start
    77     "return a new interval with elements from start to stop by step"
    77      to stop by step"
       
    78 
    78 
    79     ^ self new setFrom:start to:stop by:step
    79     ^ self new setFrom:start to:stop by:step
    80 ! !
    80 ! !
    81 
    81 
    82 !Interval class methodsFor:'converting'!
    82 !Interval class methodsFor:'converting'!
   616 ! !
   616 ! !
   617 
   617 
   618 !Interval class methodsFor:'documentation'!
   618 !Interval class methodsFor:'documentation'!
   619 
   619 
   620 version
   620 version
   621     ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.46 2008-10-22 10:49:27 cg Exp $'
   621     ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.47 2008-12-15 11:48:15 cg Exp $'
   622 ! !
   622 ! !