Andrew Nikitin wrote:
> 
> 
>> Viktor Cerovski viktor.cerovski at gmail.com 
>> Thu Dec 17 09:45:52 HKT 2009 
>> 
>> Slightly shorter/faster/neater:
>> 
>> mapply1=: 4 : 0
>> t=.ri=.0
>> while. (-.t) *. ri<#x do.
>>  'p s t'=.ri{x
>>   y=.(s , (#p) }. ])&.((z i. 1)&|.)^:(f=.+./z=.p E. y) y
>>   ri=.(-.f)*ri+1
>> end.
>> y
>> )
> 
>  
> 
> As far as I understand, the loop will stop when it reaches terminating
> rule,
> regardless of whether it is applied or not, and that is not what should
> happen.
> 
Good point.


> To make it right you can do something like this.
> 
>  
> 
> mapply3=: 4 : 0
> ri=.0
> while. ri<#x do.
>   'p s t'=.ri{x
>   y=.(s , (#p) }. ])&.((z i. 1)&|.)^:(f=.+./z=.p E. y) y
>   ri=.>:`(t * _:)@.f ri
> end.
> y
> )
> 
Perhaps smoother way to assign to ri :
  ri=. >:ri + f*t*_

-- 
View this message in context: 
http://old.nabble.com/Tacit-exercise-tp26832684s24193p26833485.html
Sent from the J Programming mailing list archive at Nabble.com.

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

Reply via email to