default.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. heapExample
  12. "HeapTest new heapExample"
  13. "Multiline
  14. decription"
  15. | n rnd array time sorted |
  16. n := 5000.
  17. "# of elements to sort"
  18. rnd := Random new.
  19. array := (1 to: n)
  20. collect: [:i | rnd next].
  21. "First, the heap version"
  22. time := Time
  23. millisecondsToRun: [sorted := Heap withAll: array.
  24. 1
  25. to: n
  26. do: [:i |
  27. sorted removeFirst.
  28. sorted add: rnd next]].
  29. Transcript cr; show: 'Time for Heap: ' , time printString , ' msecs'.
  30. "The quicksort version"
  31. time := Time
  32. millisecondsToRun: [sorted := SortedCollection withAll: array.
  33. 1
  34. to: n
  35. do: [:i |
  36. sorted removeFirst.
  37. sorted add: rnd next]].
  38. Transcript cr; show: 'Time for SortedCollection: ' , time printString , ' msecs'