appologies if repost
backtrack =: 2 : '] ([`]@.v"_) u' NB.do u if (] v u) is true otherwise undo. v is dyad, x is original y. basically uses v to select from result of u or original y. true "keeps" result of u the v expression is full rank and must return a single boolean value. Use @:] to only test result, though the left argument exists (original y) +:backtrack ([: *./ (100&>)@]) 77 44 77 44 +:backtrack ([: *./ (100&>)@]) 22 44 44 88 Though its more useful to test prior to executing u, sometimes that test is more expensive or otherwise difficult. 234345 * backtrack (4 = 3!:0@]) 1231982318 123817293871234 1231982318 123817293871234 234345 * backtrack (4 = 3!:0@]) 1231982318 123817 288708896311710 29015894865 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm