Magnitude.st
author Stefan Vogel <sv@exept.de>
Tue, 05 Feb 2008 11:26:11 +0100
changeset 10864 512cd79cee0e
parent 10600 6bfbf469a1be
child 11226 846103646b4a
permissions -rw-r--r--
Use dictionary to hold filename->generatorMethpd mapping .nsi files are generated only for applications
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
"
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
    12
"{ Package: 'stx:libbasic' }"
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
    13
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    14
Object subclass:#Magnitude
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    15
	instanceVariableNames:''
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    16
	classVariableNames:''
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    17
	poolDictionaries:''
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    18
	category:'Magnitude-General'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    21
!Magnitude class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    22
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    25
 COPYRIGHT (c) 1988 by Claus Gittinger
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    26
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    27
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    35
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    36
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    37
documentation
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    38
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    39
    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
    40
    Objects which can be compared by a kind of less than relation.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    41
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    42
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
    43
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    44
"
81dacba7a63a *** empty log message ***
claus
parents: 56
diff changeset
    45
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    46
8892
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    47
!Magnitude class methodsFor:'queries'!
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    48
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    49
isAbstract
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    50
    ^ self == Magnitude
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    51
! !
5d05a7f150a5 +isAbstract
Claus Gittinger <cg@exept.de>
parents: 8204
diff changeset
    52
10600
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    53
!Magnitude methodsFor:'Compatibility-Squeak'!
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    54
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    55
min:aMin max:aMax 
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    56
    "similar to clampBetween:and:"
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    57
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    58
    ^ (self min: aMin) max: aMax
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    59
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    60
    "Created: / 06-06-2007 / 11:00:22 / cg"
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    61
! !
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
    62
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    63
!Magnitude methodsFor:'comparing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    64
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    65
< aMagnitude
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    66
    "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
    67
     receiver is less than the argument. Otherwise return false."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    68
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    69
    ^ self subclassResponsibility
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    70
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    71
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    72
<= aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    73
    "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
    74
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    75
    ^ (aMagnitude < self) not
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    76
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    77
a27a279701f8 Initial revision
claus
parents:
diff changeset
    78
= aMagnitude
a27a279701f8 Initial revision
claus
parents:
diff changeset
    79
    "Compare the receiver with the argument and return true if the
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
     receiver is equal to the argument. Otherwise return false."
a27a279701f8 Initial revision
claus
parents:
diff changeset
    81
a27a279701f8 Initial revision
claus
parents:
diff changeset
    82
    ^ self subclassResponsibility
a27a279701f8 Initial revision
claus
parents:
diff changeset
    83
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    84
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    85
> aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    86
    "return true, if the argument is less than the receiver"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    87
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    88
    ^ aMagnitude < self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    89
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    90
a27a279701f8 Initial revision
claus
parents:
diff changeset
    91
>= aMagnitude
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    92
    "return true, if the argument is less or equal than the receiver"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
    94
    ^ (self < aMagnitude) not
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    95
!
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
    96
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    97
clampBetween:min and:max
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    98
    "return the receiver if its between min .. max,
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    99
     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
   100
     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
   101
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   102
    (max < self) ifTrue:[^ max].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   103
    (self < min) ifTrue:[^ min].
1226
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   104
    ^ self
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   105
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   106
    "
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   107
     1 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   108
     3 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   109
     6 clampBetween:2 and:5  
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   110
    "
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   111
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   112
    "Modified: 19.4.1996 / 14:58:12 / cg"
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   113
!
0beea7b0ab4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   114
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   115
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
   116
    "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
   117
     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
   118
     comparison is expensive."
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   119
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   120
    self < arg ifTrue:[
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   121
	^ lessBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   122
    ].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   123
    self = arg ifTrue:[
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   124
	^ equalBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   125
    ].
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   126
    ^ greaterBlock value
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   127
!
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   128
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   129
max:aMagnitude
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   130
    "return the receiver or the argument, whichever has greater magnitude"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   131
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   132
    (aMagnitude < self) ifTrue:[^ self].
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   133
    ^ aMagnitude
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   134
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   135
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   136
     1 max: 2
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   137
     1 max: 2.0
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   138
     2.0 max: 1.0
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   139
     2.0 max: 2
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   140
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   141
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   142
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   143
min:aMagnitude
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   144
    "return the receiver or the argument, whichever has lesser magnitude"
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   145
8181
b2560b88a5b1 Only use #< for comparisons, since this is the base mechanism.
Stefan Vogel <sv@exept.de>
parents: 8178
diff changeset
   146
    (self < aMagnitude) ifTrue:[^ self].
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   147
    ^ aMagnitude
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   148
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   149
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   150
     1 min: 2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   151
     1 min: 2.0
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   152
     2.0 min: 1.0
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   153
     2.0 min: 2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   154
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   155
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   157
!Magnitude methodsFor:'iteration'!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   158
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   159
downTo:stop do:aBlock
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   160
    "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
   161
     evaluate aBlock, passing the number as argument."
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   162
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   163
    ^ self to:stop by:-1 do:aBlock
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   164
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   165
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   166
     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
   167
     $d downTo:$a do:[:i | Transcript showCR:i].
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   168
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   169
!
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   170
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   171
to:stop by:incr do:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   172
    "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
   173
     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
   174
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   175
     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
   176
     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
   177
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   178
     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
   179
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   180
    |tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   181
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   182
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   183
"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
   184
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   185
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   186
        [tmp < stop] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   187
            aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   188
            tmp := tmp+incr
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   189
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   190
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   191
        [stop < tmp] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   192
            aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   193
            tmp := tmp+incr
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   194
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   195
    ]
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   196
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   197
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   198
     1 to:10 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   199
     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
   200
     $a to:$z by:2 do:[:i | Transcript showCR:i].
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   201
     10 to:1 by:-1 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   202
    "
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   203
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   204
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   205
to:stop by:incr doWithBreak:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   206
    "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
   207
     by step, evaluate aBlock passing the element as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   208
     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
   209
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   210
    |tmp break|
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
    break := [^ self].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   213
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   214
"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
   215
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   216
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   217
        [tmp < stop] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   218
            aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   219
            tmp := tmp+incr
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   220
        ]
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   221
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   222
        [stop < tmp] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   223
            aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   224
            tmp := tmp+incr
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
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   228
5565
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
     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
   231
        Transcript showCR:index printString.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   232
        index > 50 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   233
            break value
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   234
        ].
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   235
     ]
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
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   238
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   239
to:stop by:incr doWithExit:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   240
    "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
   241
     by step, evaluate aBlock passing the element as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   242
     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
   243
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   244
    |tmp exit|
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
    exit := [:exitValue | ^ exitValue].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   247
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   248
"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
   249
"/    incr negative ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   250
    incr < 0 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   251
        [tmp < stop] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   252
            aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   253
            tmp := tmp+incr
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
    ] ifFalse:[
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   256
        [stop < tmp] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   257
            aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   258
            tmp := tmp+incr
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
     1 to:100 by:5 doWithExit:[:index :exit |
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   264
        Transcript showCR:index printString.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   265
        index > 50 ifTrue:[
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   266
            exit value:nil
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   267
        ].
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
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   270
!
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   271
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   272
to:stop do:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   273
    "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
   274
     evaluate aBlock, passing the number as argument."
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
    |tmp|
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   277
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   278
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   279
    [stop < tmp] whileFalse:[
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   280
        aBlock value:tmp.
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   281
        tmp := tmp+1
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   282
    ]
6073
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   283
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   284
    "
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   285
     1 to:10 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   286
     1 to:10 by:2 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   287
     10 to:1 by:-1 do:[:i | Transcript showCR:i].
a2b1c61dae18 added #downTo:do:
Claus Gittinger <cg@exept.de>
parents: 5565
diff changeset
   288
    "
5565
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
to:stop doWithBreak:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   292
    "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
   293
     evaluate aBlock, passing the number as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   294
     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
   295
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   296
    |tmp break|
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
    break := [^ self].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   299
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   300
    [stop < tmp] whileFalse:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   301
        aBlock value:tmp value:break.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   302
        tmp := tmp+1
5565
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
     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
   307
        Transcript showCR:index printString.
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   308
        index > 5 ifTrue:[
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   309
            break value
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   310
        ].
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   311
     ]
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
to:stop doWithExit:aBlock
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   316
    "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
   317
     evaluate aBlock, passing the number as argument.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   318
     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
   319
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   320
    |exit tmp|
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
    exit := [:exitValue | ^exitValue].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   323
    tmp := self.
8204
ac5db5b88079 Only use the base compare mechanism, #< for iterating
Stefan Vogel <sv@exept.de>
parents: 8181
diff changeset
   324
    [stop < tmp] whileFalse:[
5565
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   325
        aBlock value:tmp value:exit.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   326
        tmp := tmp+1
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
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   330
     1 to:10 doWithExit:[:index :exit |
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   331
        index == 5 ifTrue:[
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   332
            exit value:nil
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   333
        ].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   334
        Transcript showCR:index.
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   335
     ].
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   336
    "
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   337
! !
a815d6b86ace moved iterators up in hierarchy
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   338
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   339
!Magnitude methodsFor:'testing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   340
a27a279701f8 Initial revision
claus
parents:
diff changeset
   341
between:min and:max
a27a279701f8 Initial revision
claus
parents:
diff changeset
   342
    "return whether the receiver is less than or equal to the argument max
a27a279701f8 Initial revision
claus
parents:
diff changeset
   343
     and greater than or equal to the argument min."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   344
a27a279701f8 Initial revision
claus
parents:
diff changeset
   345
    (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
   346
    (max < self) ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   347
    ^ true
56
be0ed17e6f85 *** empty log message ***
claus
parents: 5
diff changeset
   348
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   349
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   350
     1.2 between:1 and:2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   351
     (3/2) between:1 and:2
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   352
     (3/2) between:0 and:1
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   353
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   354
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   355
a27a279701f8 Initial revision
claus
parents:
diff changeset
   356
in:anInterval
a27a279701f8 Initial revision
claus
parents:
diff changeset
   357
    "return whether the receiver is within the interval bounds"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   358
a27a279701f8 Initial revision
claus
parents:
diff changeset
   359
    (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
   360
    (anInterval stop < self)  ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   361
    ^ true
56
be0ed17e6f85 *** empty log message ***
claus
parents: 5
diff changeset
   362
213
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   363
    "
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   364
     1.2 in:(1 to: 2)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   365
     (3/2) in:(1 to: 2)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   366
     (3/2) in:(0 to: 1)
3b56a17534fd *** empty log message ***
claus
parents: 93
diff changeset
   367
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   368
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   369
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   370
!Magnitude class methodsFor:'documentation'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   371
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   372
version
10600
6bfbf469a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8892
diff changeset
   373
    ^ '$Header: /cvs/stx/stx/libbasic/Magnitude.st,v 1.22 2007-06-06 08:58:05 cg Exp $'
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   374
! !