Magnitude.st
author Claus Gittinger <cg@exept.de>
Thu, 31 Mar 2005 20:49:37 +0200
changeset 8814 501f04d1f533
parent 8204 ac5db5b88079
child 8892 5d05a7f150a5
permissions -rw-r--r--
*** empty log message ***
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
a27a279701f8 Initial revision
claus
parents:
diff changeset
    48
!Magnitude methodsFor:'comparing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    49
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    50
< aMagnitude
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    51
    "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
    52
     receiver is less than the argument. Otherwise return false."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    53
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    54
    ^ self subclassResponsibility
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    55
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    56
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    57
<= aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    58
    "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
    59
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    60
    ^ (aMagnitude < self) not
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    61
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    62
a27a279701f8 Initial revision
claus
parents:
diff changeset
    63
= aMagnitude
a27a279701f8 Initial revision
claus
parents:
diff changeset
    64
    "Compare the receiver with the argument and return true if the
a27a279701f8 Initial revision
claus
parents:
diff changeset
    65
     receiver is equal to the argument. Otherwise return false."
a27a279701f8 Initial revision
claus
parents:
diff changeset
    66
a27a279701f8 Initial revision
claus
parents:
diff changeset
    67
    ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
    68
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    69
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    70
> aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    71
    "return true, if the argument is less than the receiver"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    72
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    73
    ^ aMagnitude < self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    74
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    75
a27a279701f8 Initial revision
claus
parents:
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 or equal 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
    ^ (self < aMagnitude) not
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    80
!
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    81
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    82
clampBetween:min and:max
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    83
    "return the receiver if its between min .. max,
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    84
     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
    85
     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
    86
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    87
    (max < self) ifTrue:[^ max].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    88
    (self < min) ifTrue:[^ min].
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    89
    ^ self
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    90
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    91
    "
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    92
     1 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    93
     3 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    94
     6 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    95
    "
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
    "Modified: 19.4.1996 / 14:58:12 / cg"
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    98
!
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    99
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   100
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
   101
    "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
   102
     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
   103
     comparison is expensive."
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   104
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   105
    self < arg ifTrue:[
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   106
	^ lessBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   107
    ].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   108
    self = arg ifTrue:[
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   109
	^ equalBlock value
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
    ^ greaterBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   112
!
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   113
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   114
max:aMagnitude
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   115
    "return the receiver or the argument, whichever has greater magnitude"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   116
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   117
    (aMagnitude < self) ifTrue:[^ self].
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   118
    ^ aMagnitude
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   119
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   120
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   121
     1 max: 2
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   122
     1 max: 2.0
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   123
     2.0 max: 1.0
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   124
     2.0 max: 2
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
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   128
min:aMagnitude
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   129
    "return the receiver or the argument, whichever has lesser magnitude"
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   130
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   131
    (self < aMagnitude) ifTrue:[^ self].
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   132
    ^ aMagnitude
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   133
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   134
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   135
     1 min: 2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   136
     1 min: 2.0
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   137
     2.0 min: 1.0
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   138
     2.0 min: 2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   139
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   142
!Magnitude methodsFor:'iteration'!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   143
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   144
downTo:stop do:aBlock
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   145
    "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
   146
     evaluate aBlock, passing the number as argument."
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   147
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   148
    ^ self to:stop by:-1 do:aBlock
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   149
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   150
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   151
     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
   152
     $d downTo:$a do:[:i | Transcript showCR:i].
6073
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
!
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   155
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   156
to:stop by:incr do:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   157
    "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
   158
     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
   159
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   160
     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
   161
     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
   162
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   163
     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
   164
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   165
    |tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   166
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   167
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   168
"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
   169
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   170
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   171
        [tmp < stop] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   172
            aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   173
            tmp := tmp+incr
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   174
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   175
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   176
        [stop < tmp] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   177
            aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   178
            tmp := tmp+incr
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   179
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   180
    ]
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   181
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   182
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   183
     1 to:10 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   184
     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
   185
     $a to:$z by:2 do:[:i | Transcript showCR:i].
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   186
     10 to:1 by:-1 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   187
    "
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   188
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   189
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   190
to:stop by:incr doWithBreak:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   191
    "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
   192
     by step, evaluate aBlock passing the element as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   193
     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
   194
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   195
    |tmp break|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   196
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   197
    break := [^ self].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   198
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   199
"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
   200
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   201
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   202
        [tmp < stop] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   203
            aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   204
            tmp := tmp+incr
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   205
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   206
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   207
        [stop < tmp] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   208
            aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   209
            tmp := tmp+incr
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   210
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   211
    ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   212
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   213
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   214
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   215
     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
   216
        Transcript showCR:index printString.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   217
        index > 50 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   218
            break value
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
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   222
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   223
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   224
to:stop by:incr doWithExit:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   225
    "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
   226
     by step, evaluate aBlock passing the element as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   227
     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
   228
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   229
    |tmp exit|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   230
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   231
    exit := [:exitValue | ^ exitValue].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   232
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   233
"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
   234
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   235
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   236
        [tmp < stop] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   237
            aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   238
            tmp := tmp+incr
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   239
        ]
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   240
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   241
        [stop < tmp] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   242
            aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   243
            tmp := tmp+incr
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   244
        ]
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
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   247
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   248
     1 to:100 by:5 doWithExit:[:index :exit |
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   249
        Transcript showCR:index printString.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   250
        index > 50 ifTrue:[
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   251
            exit value:nil
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
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   255
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   256
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   257
to:stop do:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   258
    "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
   259
     evaluate aBlock, passing the number as argument."
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
    |tmp|
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
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   264
    [stop < tmp] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   265
        aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   266
        tmp := tmp+1
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   267
    ]
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   268
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   269
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   270
     1 to:10 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   271
     1 to:10 by:2 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   272
     10 to:1 by:-1 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   273
    "
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   274
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   275
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   276
to:stop doWithBreak:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   277
    "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
   278
     evaluate aBlock, passing the number as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   279
     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
   280
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   281
    |tmp break|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   282
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   283
    break := [^ self].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   284
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   285
    [stop < tmp] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   286
        aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   287
        tmp := tmp+1
5565
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
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   290
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   291
     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
   292
        Transcript showCR:index printString.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   293
        index > 5 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   294
            break value
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   295
        ].
5565
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
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   298
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   299
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   300
to:stop doWithExit:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   301
    "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
   302
     evaluate aBlock, passing the number as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   303
     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
   304
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   305
    |exit tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   306
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   307
    exit := [:exitValue | ^exitValue].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   308
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   309
    [stop < tmp] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   310
        aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   311
        tmp := tmp+1
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
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   314
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   315
     1 to:10 doWithExit:[:index :exit |
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   316
        index == 5 ifTrue:[
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   317
            exit value:nil
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
        Transcript showCR:index.
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
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   322
! !
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   323
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   324
!Magnitude methodsFor:'testing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   325
a27a279701f8 Initial revision
claus
parents:
diff changeset
   326
between:min and:max
a27a279701f8 Initial revision
claus
parents:
diff changeset
   327
    "return whether the receiver is less than or equal to the argument max
a27a279701f8 Initial revision
claus
parents:
diff changeset
   328
     and greater than or equal to the argument min."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   329
a27a279701f8 Initial revision
claus
parents:
diff changeset
   330
    (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
   331
    (max < self) ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   332
    ^ true
56
be0ed17e6f85 *** empty log message ***
claus
parents: 5
diff changeset
   333
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   334
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   335
     1.2 between:1 and:2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   336
     (3/2) between:1 and:2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   337
     (3/2) between:0 and:1
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   338
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   339
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   340
a27a279701f8 Initial revision
claus
parents:
diff changeset
   341
in:anInterval
a27a279701f8 Initial revision
claus
parents:
diff changeset
   342
    "return whether the receiver is within the interval bounds"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   343
a27a279701f8 Initial revision
claus
parents:
diff changeset
   344
    (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
   345
    (anInterval stop < self)  ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   346
    ^ true
56
be0ed17e6f85 *** empty log message ***
claus
parents: 5
diff changeset
   347
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   348
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   349
     1.2 in:(1 to: 2)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   350
     (3/2) in:(1 to: 2)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   351
     (3/2) in:(0 to: 1)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   352
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   353
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   354
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   355
!Magnitude class methodsFor:'documentation'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   356
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   357
version
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   358
    ^ '$Header: /cvs/stx/stx/libbasic/Magnitude.st,v 1.20 2004-03-16 09:00:23 stefan Exp $'
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   359
! !