Contents    Page-10    Prev    Next    Page+10    Index   

Smalltalk Code


|  minLength i j |
	
  minLength := self length.
 
  100 timesRepeat:
   [i := ((Float random * self size) truncate + 1)
            asInteger.
    j := ((Float random * self size) truncate + 1)
            asInteger.
    self exchange: i and: j.
    self length < minLength             
         ifTrue: [minLength := self length]
         ifFalse: [self exchange: i and: j]]