Debian Codegraph @

test/syntax/source/code/smalltalk

raw
1 Object>>method: num
2 "comment 123"
3 | var1 var2 |
4 (1 to: num) do: [:i | |var| ^i].
5 Klass with: var1.
6 Klass new.
7 arr := #('123' 123.345 #hello Transcript var $@).
8 arr := #().
9 var2 = arr at: 3.
10 ^ self abc
11
12 heapExample
13 "HeapTest new heapExample"
14 "Multiline
15 decription"
16 | n rnd array time sorted |
17 n := 5000.
18 "# of elements to sort"
19 rnd := Random new.
20 array := (1 to: n)
21 collect: [:i | rnd next].
22 "First, the heap version"
23 time := Time
24 millisecondsToRun: [sorted := Heap withAll: array.
25 1
26 to: n
27 do: [:i |
28 sorted removeFirst.
29 sorted add: rnd next]].
30 Transcript cr; show: 'Time for Heap: ' , time printString , ' msecs'.
31 "The quicksort version"
32 time := Time
33 millisecondsToRun: [sorted := SortedCollection withAll: array.
34 1
35 to: n
36 do: [:i |
37 sorted removeFirst.
38 sorted add: rnd next]].
39 Transcript cr; show: 'Time for SortedCollection: ' , time printString , ' msecs'