> 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.
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
)


 
                                          
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to