Class new title: Set subclassof: Stream fields: 'views' declare: ''  t1 [array  t1]  t1 _ t2 [position + 1 = t1  [self next_ t2] array  t1 _ t2] add: t1 [self next_ t1] append: t1 | [for t1 from: t1 do [self next_ t1]] asSet asStream [self viewer] checkIndex: t1 [t1  1 and t1  position  [t1] user notify: 'illegal index'] copy [self viewer copy] default [self vector: 8] delete: t1 | t2 [for t2 to: position do [array  t2  t1  [self deleteI: t2]]. false] deleteI: t1 | t2 t3 [t2 _ self  t1. for t3 from: t1 to: position - 1 do [array  t3 _ array  (t3 + 1)]. array  position _ nil. position _ position - 1. t2] deleteI: t1 to: t2 | t3 t4 [t3 _ t2 - t1 + 1. for t4 from: t1 to: position - t3 do [array  t4 _ array  (t4 + t3)]. for t4 from: position - t3 + 1 to: position do [array  t4 _ nil]. position _ position - t3] dotproduct: t1 | t2 t3 [t3 _ 0.0. self length = t1 length  [for t2 to: position do [t3 _ t3 + (t1  t2 * (self  t2))]. t3] user notify: 'dot product undefined...sets are not of equal length'] find: t1 | t2 [for t2 to: position do [array  t2 = t1  [t2]]. 0] grow [self growby: (10 max: limit / 4)] growby: t1 | t2 [t2 _ Set new of: array to: position. self of: (array species new: limit + t1) to: 0. t2] has: t1 [(self find: t1) > 0] initView: t1 [t1 of: array to: position] insert: t1 [(self find: t1) = 0  [self next_ t1]] insertI: t1 value: t2 | t3 t4 [t1 > position  [self next_ t2] t3 _ array. [position = limit  [limit _ limit + (10 max: limit / 4). array _ array species new: limit. for t4 to: t1 - 1 do [array  t4 _ t3  t4]]]. for t4 from: position to: t1 by: 1 do [array  t4 + 1 _ t3  t4]. array  t1 _ t2. position _ position + 1] length [position] next [user notify: 'no direct reading of a Set'] notViewed: t1 [views delete: t1. views empty  [views _ nil]] of: t1 to: t2 [array _ t1. position _ t2. limit _ array length] pastend_ t1 [self append: self grow. self next_ t1] printon: t1 | t2 [t1 append: 'a Set: '. array is: String  [t1 append: self] for t2 from: self do [t1 space. t1 print: t2]] product: t1 | t2 t3 [t2 _ Set new default. self length = t1 length  [for t3 to: position do [t2 add: t1  t3 * (self  t3)]. t2] user notify: 'product undefined...sets are not of equal length'] species [array species] string: t1 [limit _ t1. self of: (String new: limit)] summation | t1 t2 [t2 _ 0.0. for t1 to: position do [t2 _ t2 + (self  t1)]. t2] vector: t1 [limit _ t1. self of: (Vector new: limit)] viewRange: t1 to: t2 [SetReader new of: array from: t1 to: t2] viewer [SetReader new of: array from: 1 to: position] viewer: t1 [[views  nil  [views _ Set default]]. views next_ t1]