Magnitude.st
author Claus Gittinger <cg@exept.de>
Thu, 12 Oct 2006 21:33:18 +0200
changeset 10084 f6af35f81242
parent 8892 5d05a7f150a5
child 10600 6bfbf469a1be
permissions -rw-r--r--
extension code refactored
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
    13
"{ Package: 'stx:libbasic' }"
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
    14
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    15
Object subclass:#Magnitude
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    16
	instanceVariableNames:''
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    17
	classVariableNames:''
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    18
	poolDictionaries:''
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    19
	category:'Magnitude-General'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    22
!Magnitude class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    23
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    24
copyright
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    25
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    26
 COPYRIGHT (c) 1988 by Claus Gittinger
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    27
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    28
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    29
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    30
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    32
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    33
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    34
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    35
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    36
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    37
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    38
documentation
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    39
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    40
    This is an abstract class definining common methods for
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    41
    Objects which can be compared by a kind of less than relation.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    42
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    43
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    44
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    45
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    46
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    47
8892
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    48
!Magnitude class methodsFor:'queries'!
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    49
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    50
isAbstract
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    51
    ^ self == Magnitude
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    52
! !
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    53
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    54
!Magnitude methodsFor:'comparing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    55
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    56
< aMagnitude
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
    "Compare the receiver with the argument and return true if the
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    58
     receiver is less than the argument. Otherwise return false."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    59
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    60
    ^ self subclassResponsibility
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    61
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    62
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    63
<= aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    64
    "return true, if the argument is greater or equal than the receiver"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    65
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    66
    ^ (aMagnitude < self) not
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    67
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    68
a27a279701f8 Initial revision
claus
parents:
diff changeset
    69
= aMagnitude
a27a279701f8 Initial revision
claus
parents:
diff changeset
    70
    "Compare the receiver with the argument and return true if the
a27a279701f8 Initial revision
claus
parents:
diff changeset
    71
     receiver is equal to the argument. Otherwise return false."
a27a279701f8 Initial revision
claus
parents:
diff changeset
    72
a27a279701f8 Initial revision
claus
parents:
diff changeset
    73
    ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
    74
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    75
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    76
> aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    77
    "return true, if the argument is less than the receiver"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    78
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    79
    ^ aMagnitude < self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    81
a27a279701f8 Initial revision
claus
parents:
diff changeset
    82
>= aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    83
    "return true, if the argument is less or equal than the receiver"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    84
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    85
    ^ (self < aMagnitude) not
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    86
!
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    87
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    88
clampBetween:min and:max
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    89
    "return the receiver if its between min .. max,
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    90
     or min if its less than min, or max of its greater than max.
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    91
     This is only a lazy-typers helper for: ((something min:max) max:min)"
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    92
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    93
    (max < self) ifTrue:[^ max].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    94
    (self < min) ifTrue:[^ min].
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    95
    ^ self
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    96
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    97
    "
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    98
     1 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    99
     3 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   100
     6 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   101
    "
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   102
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   103
    "Modified: 19.4.1996 / 14:58:12 / cg"
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   104
!
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   105
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   106
compare:arg ifLess:lessBlock ifEqual:equalBlock ifGreater:greaterBlock
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   107
    "three-way compare - thanks to Self for this idea.
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   108
     Can be redefined in subclasses to do it with a single comparison if
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   109
     comparison is expensive."
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   110
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   111
    self < arg ifTrue:[
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   112
	^ lessBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   113
    ].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   114
    self = arg ifTrue:[
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   115
	^ equalBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   116
    ].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   117
    ^ greaterBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   118
!
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   119
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   120
max:aMagnitude
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   121
    "return the receiver or the argument, whichever has greater magnitude"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   122
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   123
    (aMagnitude < self) ifTrue:[^ self].
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   124
    ^ aMagnitude
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   125
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   126
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   127
     1 max: 2
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   128
     1 max: 2.0
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   129
     2.0 max: 1.0
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   130
     2.0 max: 2
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   131
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   132
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   133
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   134
min:aMagnitude
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   135
    "return the receiver or the argument, whichever has lesser magnitude"
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   136
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   137
    (self < aMagnitude) ifTrue:[^ self].
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   138
    ^ aMagnitude
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   139
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   140
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   141
     1 min: 2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   142
     1 min: 2.0
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   143
     2.0 min: 1.0
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   144
     2.0 min: 2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   145
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   146
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   147
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   148
!Magnitude methodsFor:'iteration'!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   149
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   150
downTo:stop do:aBlock
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   151
    "For each element of the interval from the receiver down to the argument stop,
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   152
     evaluate aBlock, passing the number as argument."
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   153
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   154
    ^ self to:stop by:-1 do:aBlock
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   155
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   156
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   157
     10 downTo:1 do:[:i | Transcript showCR:i].
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   158
     $d downTo:$a do:[:i | Transcript showCR:i].
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   159
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   160
!
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   161
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   162
to:stop by:incr do:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   163
    "For each element of the interval from the receiver up to the argument stop, incrementing
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   164
     by step, evaluate aBlock passing the element as argument.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   165
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   166
     Not all Magnitudes do implement #negative and #+ however, 
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   167
     so should this method go to ArithmethicValue?
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   168
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   169
     Only use #<, to speed up things (for subclasses only defining #<)"
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   170
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   171
    |tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   172
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   173
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   174
"using #negative would be more portable, but stc does only inline #< but not #negative (yet)"
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   175
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   176
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   177
        [tmp < stop] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   178
            aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   179
            tmp := tmp+incr
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   180
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   181
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   182
        [stop < tmp] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   183
            aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   184
            tmp := tmp+incr
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   185
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   186
    ]
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   187
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   188
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   189
     1 to:10 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   190
     1 to:10 by:2 do:[:i | Transcript showCR:i].
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   191
     $a to:$z by:2 do:[:i | Transcript showCR:i].
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   192
     10 to:1 by:-1 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   193
    "
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   194
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   195
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   196
to:stop by:incr doWithBreak:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   197
    "For each element of the interval from the receiver up to the argument stop, incrementing
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   198
     by step, evaluate aBlock passing the element as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   199
     Pass a break argument, to allow for premature exit of the loop."
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   200
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   201
    |tmp break|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   202
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   203
    break := [^ self].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   204
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   205
"using #negative would be more portable, but stc does only inline #< but not #negative (yet)"
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   206
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   207
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   208
        [tmp < stop] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   209
            aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   210
            tmp := tmp+incr
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   211
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   212
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   213
        [stop < tmp] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   214
            aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   215
            tmp := tmp+incr
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   216
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   217
    ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   218
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   219
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   220
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   221
     1 to:100 by:5 doWithBreak:[:index :break |
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   222
        Transcript showCR:index printString.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   223
        index > 50 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   224
            break value
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   225
        ].
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   226
     ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   227
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   228
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   229
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   230
to:stop by:incr doWithExit:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   231
    "For each element of the interval from the receiver up to the argument stop, incrementing
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   232
     by step, evaluate aBlock passing the element as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   233
     Pass a break argument, to allow for premature exit of the loop."
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   234
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   235
    |tmp exit|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   236
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   237
    exit := [:exitValue | ^ exitValue].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   238
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   239
"using #negative would be more portable, but stc does only inline #< but not #negative (yet)"
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   240
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   241
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   242
        [tmp < stop] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   243
            aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   244
            tmp := tmp+incr
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   245
        ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   246
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   247
        [stop < tmp] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   248
            aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   249
            tmp := tmp+incr
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   250
        ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   251
    ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   252
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   253
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   254
     1 to:100 by:5 doWithExit:[:index :exit |
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   255
        Transcript showCR:index printString.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   256
        index > 50 ifTrue:[
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   257
            exit value:nil
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   258
        ].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   259
     ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   260
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   261
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   262
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   263
to:stop do:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   264
    "For each element of the interval from the receiver up to the argument stop,
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   265
     evaluate aBlock, passing the number as argument."
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   266
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   267
    |tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   268
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   269
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   270
    [stop < tmp] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   271
        aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   272
        tmp := tmp+1
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   273
    ]
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   274
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   275
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   276
     1 to:10 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   277
     1 to:10 by:2 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   278
     10 to:1 by:-1 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   279
    "
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   280
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   281
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   282
to:stop doWithBreak:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   283
    "For each element of the interval from the receiver up to the argument stop,
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   284
     evaluate aBlock, passing the number as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   285
     Pass a break argument, to allow for premature exit of the loop."
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   286
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   287
    |tmp break|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   288
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   289
    break := [^ self].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   290
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   291
    [stop < tmp] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   292
        aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   293
        tmp := tmp+1
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   294
    ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   295
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   296
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   297
     1 to:10 doWithBreak:[:index :break |
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   298
        Transcript showCR:index printString.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   299
        index > 5 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   300
            break value
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   301
        ].
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   302
     ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   303
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   304
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   305
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   306
to:stop doWithExit:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   307
    "For each element of the interval from the receiver up to the argument stop,
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   308
     evaluate aBlock, passing the number as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   309
     An exitBlock is passed as second argument, which allows for the loop to be terminated early."
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   310
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   311
    |exit tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   312
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   313
    exit := [:exitValue | ^exitValue].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   314
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   315
    [stop < tmp] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   316
        aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   317
        tmp := tmp+1
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   318
    ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   319
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   320
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   321
     1 to:10 doWithExit:[:index :exit |
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   322
        index == 5 ifTrue:[
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   323
            exit value:nil
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   324
        ].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   325
        Transcript showCR:index.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   326
     ].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   327
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   328
! !
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   329
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   330
!Magnitude methodsFor:'testing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   331
a27a279701f8 Initial revision
claus
parents:
diff changeset
   332
between:min and:max
a27a279701f8 Initial revision
claus
parents:
diff changeset
   333
    "return whether the receiver is less than or equal to the argument max
a27a279701f8 Initial revision
claus
parents:
diff changeset
   334
     and greater than or equal to the argument min."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   335
a27a279701f8 Initial revision
claus
parents:
diff changeset
   336
    (self < min) ifTrue:[^ false].
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   337
    (max < self) ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   338
    ^ true
56
be0ed17e6f85 *** empty log message ***
claus
parents: 5
diff changeset
   339
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   340
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   341
     1.2 between:1 and:2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   342
     (3/2) between:1 and:2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   343
     (3/2) between:0 and:1
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   344
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   345
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   346
a27a279701f8 Initial revision
claus
parents:
diff changeset
   347
in:anInterval
a27a279701f8 Initial revision
claus
parents:
diff changeset
   348
    "return whether the receiver is within the interval bounds"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   349
a27a279701f8 Initial revision
claus
parents:
diff changeset
   350
    (self < anInterval start) ifTrue:[^ false].
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   351
    (anInterval stop < self)  ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   352
    ^ true
56
be0ed17e6f85 *** empty log message ***
claus
parents: 5
diff changeset
   353
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   354
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   355
     1.2 in:(1 to: 2)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   356
     (3/2) in:(1 to: 2)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   357
     (3/2) in:(0 to: 1)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   358
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   359
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   360
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   361
!Magnitude class methodsFor:'documentation'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   362
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   363
version
8892
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
   364
    ^ '$Header: /cvs/stx/stx/libbasic/Magnitude.st,v 1.21 2005-06-27 10:20:44 cg Exp $'
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   365
! !