> From: Sherlock, Ric
>
> > From: Jose Mario Quintana
> > This version of "while" is shorter, leaner and faster than my
> > original suggestion,
> >
> >    u while v
> > 0&({::)@:((u^:([`1:`(0&({::)@])) ,&< -.@:(1&({::)@:]))^:(''"_ $
> > ,@:(v^:([`1:`(0&({::)@]))))^:_^:([`1:`((] ,&< 0:)@])))
> >
>
> I had a go at adapting this approach to my solution:
> 
> NB. NOT USING WHILE
> notperfect =: (0 < fitness) {:
> nextgen    =: ] , [ select {:@] , mr...@[ mutate NPROG copy {:@]
> evolve=: nextgen ^: notperfect ^:_ ,:@populate
> 
> NB. USING WHILE
> while      =: 2 : '(((] , (u {:))^:(v {:)^:_) ,:)'
> notperfect1=: 0 < fitness
> nextgen1   =: select ] , mr...@[ mutate NPROG copy ]
> evolve1=: nextgen1 while notperfect1 populate
> 
> I'm not sure I know which version I like better. The while certainly
> cleans up the other verbs, letting them concentrate on their core
> purpose, but even this much simpler while, adds an extra line of dense
> code.

Actually there are a couple of sets of redundant brackets in my while. Removing 
them makes it much more appealing to me - I find it hard to parse sentences 
with lots of brackets.

while =: 2 : '(] , (u {:))^:(v {:)^:_ ,:'


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to