All pastes #446439 Raw Edit

huh?

public text v1 · immutable
·published 2007-04-18 14:03 UTC
rendered paste body
Stvorenie := Object clone do(
  geny := List clone
  
  novyGenom := method(zg, pg,
    for(n, 1, pg,
      g := zg at(Random value(zg size) floor) // don't copy, just make them referenced in the local list
     
      geny append(g)
    )
  )
  
  vytvorNovy := method(zg, pg,
    result := Stvorenie clone
    //result geny = [] // why should this be needed?
    result novyGenom(zg, pg)
    result
  )
  
  asString = method(
    result := "0"
    
    geny foreach(g,
      result = result + g asString
    )
    result
  )
)

// zoznamGenov is a list with genes

s := Stvorenie clone
s novyGenom(zoznamGenov, 5)
s println
s := Stvorenie clone
s novyGenom(zoznamGenov, 5)
s println

/////////////////////// results in ///////////////////////
0+X/X*X*X*X
0+X/X*X*X*X/3*2/X+X-3
 
for example, it should be 2 lines with "5" genes each