Exercism  Check-in [19e3c59e3d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the access pattern to coerce to array earlier. This handily doubles up on hiding the inner mutability, as arrays shouldn't be added to and will complain.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: 19e3c59e3dc699768ec640efb9276cb8add1bcf846b0ef14d69de02cc1313069
User & Date: jaccarmac 2022-06-07 17:53:59.370
Original Comment: Change the access pattern to coerce to array earlier.
Context
2022-06-07
17:53
Change the access pattern to coerce to array earlier. Leaf check-in: 19e3c59e3d user: jaccarmac tags: trunk
15:03
Use the SortFunction messages. check-in: 7dddc9f5fd user: jaccarmac tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to pharo-smalltalk/grade-school/GradeSchool.class.st.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

19
20

21
22
23
24
25
26
27

28
29
30
31
32
33






34
Class {
	#name : #GradeSchool,
	#superclass : #Object,
	#instVars : [
		'roster'
	],
	#category : #'Exercise@GradeSchool'
}

{ #category : #accessing }
GradeSchool >> addStudents: aCollection [

	roster addAll: aCollection
]

{ #category : #accessing }
GradeSchool >> desiredGrade: anInteger [


	^ (roster select: [ :s | s second = anInteger ] thenCollect: #first)
		  asArray

]

{ #category : #initialization }
GradeSchool >> initialize [

	super initialize.
	roster := SortedCollection sortUsing: #second ascending, #first ascending

]

{ #category : #accessing }
GradeSchool >> roster [

	^ (roster collect: #first) asArray






]




|







|





>
|
<
>






|
>





|
>
>
>
>
>
>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Class {
	#name : #GradeSchool,
	#superclass : #Object,
	#instVars : [
		'students'
	],
	#category : #'Exercise@GradeSchool'
}

{ #category : #accessing }
GradeSchool >> addStudents: aCollection [

	students addAll: aCollection
]

{ #category : #accessing }
GradeSchool >> desiredGrade: anInteger [

	^ self students
		  select: [ :s | s second = anInteger ]

		  thenCollect: #first
]

{ #category : #initialization }
GradeSchool >> initialize [

	super initialize.
	students := SortedCollection sortUsing:
		            #second ascending , #first ascending
]

{ #category : #accessing }
GradeSchool >> roster [

	^ self students collect: #first
]

{ #category : #accessing }
GradeSchool >> students [

	^ students asArray
]
Changes to pharo-smalltalk/grade-school/TestResults.txt.
1
2
3
4
5
Tested on: 2022-06-07 10:03
8 run, 8 passes, 0 skipped, 0 failures, 0 errors.
Used OS/Platform: unix linux-gnu x86_64
Image version: Pharo11.0.0 build: 62 (64 Bit)
VM version: eda1de4 - Commit: eda1de4 - Date: 2022-05-18 11:51:47 +0200
|




1
2
3
4
5
Tested on: 2022-06-07 12:53
8 run, 8 passes, 0 skipped, 0 failures, 0 errors.
Used OS/Platform: unix linux-gnu x86_64
Image version: Pharo11.0.0 build: 62 (64 Bit)
VM version: eda1de4 - Commit: eda1de4 - Date: 2022-05-18 11:51:47 +0200