I want to pull all rows from a boxed table that I've created in J, based on specific values in certain columns. This is similar to using WHERE <colvalue> = <value> to formulate SQL queries. In J I can do this by hand using standard J operators. Now I would like to pull it into a dyadic verb but I'm having trouble deciding the most common way to formulate the arguments. The y value is easy it will the variable that holds the table data (in this case I call it "dat"). But now having used my y argument I now need to stuff into the x argument the column numbers I want to base selection from and the strings that will be used to test for equality. Just so you get a feeling for what I'm trying to do the by hand formulation is as follows:

((2 }"1 dat) = <, 'Tom') *. (4}"1 dat) = <, 'McGuie'

The above giving me a boolean array where the ones represent the rows where col 2 = Tom and Col4 =McGuire. Then I can just apply the answer with copy (#) to give me a new array with just those rows that are equal in col2 and col4.

So is there a better way to organize this? Do you make the table "dat" global freeing up the y argument? I can certainly brute force this but I'm hoping for a more elegant solution that will be applicable to future problem spaces.

Tom McGuire


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

Reply via email to