This preview shows page 1. Sign up to view the full content.
Unformatted text preview: greater than zero numbers found in A into a variable S . (i.e., S will equal 212) (10 pts) |A S| A := OrderedCollection new:5. A:= #(21 -4 -11 10 191). S:= 0. A do:[:i| (i odd) & (i >0 ) ifTrue: [S := S + i]]. S. 212 A collect :[:i| (i odd) & (i >0 ) ifTrue: [S := S + i]]. “will also wor” Extra Credit: (10 pts extra, no deduction for a wrong answer, but it must be complete answer no partial credits!). 3)Write a Smalltalk code that defines a (4 by 4) matrix A and initializes all of its elements to the value of 2; then multiplies A by itself and stores the results back in A. (10 pts) |A| A:= Matrix new:4 element:2. “create A 4X4 matrix with all elements of 4.” Also correct to write” A;= Matrix rows:4 columns:4 element:2. A := A preMultiplyByMatrix: A. “multiply A by itself”...
View Full Document
This note was uploaded on 08/23/2011 for the course CSE 324 taught by Professor Soliman during the Spring '11 term at NMT.
- Spring '11