I see.
In that case, based on only a cursory examination, I might suggest you break
out the evolution step like this:
evo1=: 3 : 0
p=. 1+?#y
tc=. ord (p-1){y
vk=. (?3){chr (32+?95), (tc+1), tc-1
kind=. vk (p-1)}y
kinds=. pw ffit kind
kind;<kinds
)
then alter your loop to test a batch of mutations at once:
...
while. 0<s do.
'kind kinds'=. evo1 &> 10$<oud
wh=. kinds i. </kinds,s
's oud'=. wh{&>(kinds,s);<kind,oud
g=.g+1
NB. ('gen: ',(":g),'(',(":s),') ',oud) (1!:2) 2
end.
...
(I haven't tested the above so it may have a simple error or two)
The other thing I might do would be to eliminate the conversions between
character and numeric inside the
loop - it looks more natural to work completely with integers, perhaps
converting once at the top of the
function and converting back at the bottom.
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm