Hi!

I need test function f on array x1 x2 ... xn

If f(x) = 0 then no need test another member of array.

I don't understand how write this code loopless.

Main thing: I would avoid of waste computation of f(x) if f(x) = C found.

I think about Fold but I see only ugly decision with using global variables.

Example code for rewriting:

NB. Vector with test values
a =: 1 + i. y
f =: *:

example =: monad : 0
for_i. a do.
 if. 25 = f i do.
   i return.
 end.
0
end.
)

example a

Nice day!
Sergey



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

Reply via email to