Quoting cdrick cdrick65@gmail.com:
testMaleMeiosis2 | resultArray tesSet | testSet := strand testRun. resultArray := Forecaster testMale meiose inject: #(0 0) into: [:array :val | array at: 1 put: (array at: 1) + testSet maternalCount. array at: 2 put: (array at: 2) + testSet paternalCount. array]
self should: [ resultArray = #(100 100)].
thanks Cédrick. Yes, that's what I was trying to do earlier, but without success. Perhaps a missing explicit return somewhere.
Quoting "Randal L. Schwartz" merlyn@stonehenge.com:
| testSets mTotal pTotal |
testSets := (Forecaster testMale meiose) collect: [:strand | strand testRun ]. mTotal := (testSets collect: [:each | each maternalCount]) sum. pTotal := (testSets collect: [:each | each paternalCount]) sum.
Randal, much more succinct than my effort, thanks.
Quoting Zulq Alam me@zulq.net:
Hi Stan,
How about using #detectSum:?
testMaleMeiosis2 pTotal := Forecaster testMale meiose detectSum: [:strand | strand testRun paternalCount]. mTotal := Forecaster testMale meiose detectSum: [:strand | strand testRun maternalCount]. self should: [mTotal = 100 and: [pTotal = 100]]
detectSum: neatens things up nicely, Zulq. I dont think I can call meiose twice in this case, because it returns different strands each time, intentionally. It randomly swaps genes between strands as in genetic recombination, and that's what I'm trying to test.
So until the next cunning suggestion, at the moment it looks like:
testMaleMeiosis3 | testSets mTotal pTotal | testSets := Forecaster testMale meiose collect: [:strand | strand testRun]. mTotal := testSets detectSum: [:each | each maternalCount]. pTotal := testSets detectSum: [:each | each paternalCount]. self should: [mTotal = 100 and: [pTotal = 100]]
I appreciate all your replies; very illuminating.
...Stan