| ||
Student Originated Software 1997-1998
| ||
A Software Engineering Course at The Evergreen State College | ||
|
Smalltalk Solutions for Week 3 assignmentExercise 10.1
index := 0. addBlock := [index:= index+1]. 5 timesRepeat: [
Transcript cr. Transcript show: 'index: ',index printString. Exercise 10.4| a b |a:=0. b:=0.
Transcript cr; show: b printString.
1 to: 100 do: [:n |
Transcript cr. Transcript show: 'sum: ',sum printString. Exercise 10.6| myArray index max |
index := 1. max := myArray at:1. [(index+1) <= myArray size]
(myArray at: index) > max
| maxBlock max |
Transcript cr. Transcript show: 'max: ',max printString. Exercise 10.7| myArray i j temp |
i:=1. j := myArray size. (j//2) timesRepeat: [temp := myArray at:i. myArray at:i put: (myArray at:j). myArray at:j put: temp. i := i+1. j := j-1]. #(6 5 4 3 2 1)
| swapBlock reverseBlock array |
i = j ifFalse: [
anArray at: j put: (anArray at: i). anArray at: i put: tmp reverseBlock := [:anArray |
i := 1. j := anArray size. [
i := i +1. j := j - 1. i < j reverseBlock value: array. Transcript cr. Transcript show: 'array: ', array printString. Exercise 10.10| counter |counter := 0. [counter < 10] whileTrue: [
Transcript cr. Transcript show: counter printString, ' squared: ', (counter * counter) printString. ]. |