add comments to smalltalk impl
This commit is contained in:
parent
4ed9cdf46a
commit
1ceca09860
1 changed files with 15 additions and 1 deletions
|
@ -23,12 +23,14 @@ Object subclass: GF [
|
|||
ifTrue: [Error signal: 'both arguments must have the same characteristic']
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
+ rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^GF create: characteristic
|
||||
withValue: ((value + rhs value) \\ characteristic)
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
- rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
"^GF create: characteristic
|
||||
|
@ -46,12 +48,15 @@ Object subclass: GF [
|
|||
].
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
* rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^GF create: characteristic
|
||||
withValue: ((value * rhs value) \\ characteristic)
|
||||
]
|
||||
|
||||
"throws ZeroDivide on division by 0"
|
||||
"throws Error on different characteristics"
|
||||
/ rhs [
|
||||
| inverse |
|
||||
self verifyCharacteristics: rhs.
|
||||
|
@ -67,44 +72,53 @@ Object subclass: GF [
|
|||
withValue: ((value * inverse) \\ characteristic)
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
= rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^value = rhs value
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
~= rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^value ~= rhs value
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
> rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^value > rhs value
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
< rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^value < rhs value
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
>= rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^value >= rhs value
|
||||
]
|
||||
|
||||
"throws Error on different characteristics"
|
||||
<= rhs [
|
||||
self verifyCharacteristics: rhs.
|
||||
^value <= rhs value
|
||||
]
|
||||
|
||||
"returns the characteristic of `self`"
|
||||
characteristic [
|
||||
^characteristic
|
||||
]
|
||||
|
||||
"returns the value of `self`"
|
||||
value [
|
||||
^value
|
||||
]
|
||||
|
||||
"prints `self` in a pretty format"
|
||||
displayOn: stream [
|
||||
'GF<' displayOn: stream.
|
||||
characteristic displayOn: stream.
|
||||
|
|
Loading…
Reference in a new issue