try Y`X @. +./ X e. Foo"_1 input
R.E. Boss > -----Oorspronkelijk bericht----- > Van: [email protected] [mailto:[email protected]] Namens > Alexander Mikhailov > Verzonden: woensdag 9 juni 2010 8:21 > Aan: [email protected] > Onderwerp: [Jchat] on the J thought style again > > I'm writing a function which goes roughly as the following: "from the > input array, take first element and do Foo to it. If the result is X, > stop, otherwise get second element and do Foo to it. If the result is X, > stop... etc. If the result of last element is still not X, return Y" > > I started to write like this: > > Foo y > > and then I realize that I'm doing Foo to all elements of input at once, > even those which potentially won't be needed. > > So, trying to be optimal complicates things. A familiar observation. > > What would be an advice to J-ers? Clarity of idea - or, in extreme cases, > soundness of algorithm? Or, rather, how to find a balance here? > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
