Skip to content

Commit 9709c54

Browse files
refactor: using Parallel Change, introduced a new message that returns roots in order.
1 parent d9a495e commit 9709c54

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Math-Polynomials/PMPolynomial.class.st

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ PMPolynomial >> negated [
193193
^ self * -1
194194
]
195195

196+
{ #category : #information }
197+
PMPolynomial >> orderedRoots [
198+
"comment stating purpose of instance-side method"
199+
"scope: class-variables & instance-variables"
200+
201+
^ self roots asSortedCollection asArray
202+
]
203+
196204
{ #category : #printing }
197205
PMPolynomial >> printOn: aStream [
198206
"Append to aStream a written representation of the receiver."

src/Math-Tests-Polynomials/PMPolynomialTest.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ PMPolynomialTest >> testPolynomialRoots [
235235

236236
| polynomial roots |
237237
polynomial := PMPolynomial coefficients: #( -10 -13 -2 1 ).
238-
roots := polynomial roots asSortedCollection asArray.
238+
roots := polynomial orderedRoots .
239239
self assert: roots size equals: 3.
240240
self assert: (roots at: 1) + 2 closeTo: 0.
241241
self assert: (roots at: 2) + 1 closeTo: 0.

0 commit comments

Comments
 (0)