Here's a debugged version incorporating my suggestions:
evolueer2=: 4 : 0
'x oud'=. ord &.> x;y
s=. x ffit2 oud
g=. 0
(('gen: '),(":g),'(',(":s),')',chr oud) (1!:2) 2
while. 0<s do.
'kind kinds'=. |:(<x) evo2 &> 10$<oud
wh=. kinds i. <./kinds,s
's oud'=. wh{&.>(kinds,s);<kind,oud
g=.g+1
end.
'gen: ',(":g),'(',(":s),') ',chr oud
)
evo2=: 4 : 0
p=. ?#y
tc=. p{y
vk=. (?3){(32+?95),tc+1 _1
kind=. vk p}y
kinds=. x ffit2 kind
kind;<kinds
)
On 12/3/07, Devon McCormick <[EMAIL PROTECTED]> wrote:
>
> 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
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm