In multidimensional indexing, q uses null (::
) to mean “all”.
m[;2 3] / columns 2 and 3 and all of the rows
Follow suit; for example
copy:{[table;fields]
…
if[fields~::;fields:til table];
…
}
copy:{[table;fields]
if[fields~();:()];
if[fields~::;fields:til table];
…
}
If the arguments to a function are not independent, order them left-to-right in dependency order. That is, argument i
restricts the choice made by argument i-1
. In particular, try to arrange things so that if argument i
is null, all arguments to the right of i
are logically null. In the example above, it would be a mistake to order the arguments
copy:{[fields;table]
…
}
foo:{
if[x~::;x:()]
…
}