On Thu, Nov 20, 2008 at 11:24 PM, Swee Heng wrote:> Here's something I find perplexing:>> The following definition of f works:> q)t:([]a:til 10;b:10?10f)> q)f:{[x;y]select from x where a within y}> q)f[t;3 5]> a b> ----------> 3 6.254256> 4 3.667316> 5 9.844223>> But when [x;y] is omitted, why does it fail with 'rank:> q)f:{select from x where a within y}> q)f[t;3 5]> 'rank>> Switch around the function arguments and it works even without> explicit declaration of [x;y]:> q)f:{select from y where a within x}> q)f[3 5;t]> a b> ----------> 3 6.254256> 4 3.667316> 5 9.844223>> Would appreciate it if someone can enlighten me on this rather non-> intuitive aspect of function definitions.a classic gotchaq (mis)interprets a y in the where clause as a column name if thereare no other indicators that it's a parameterq)unshow get{[x;y]select from x where a within y}(0x0ba0a178a20a040005;`x`y;`symbol$();,`;0b;,(within;`a;`y);?;"{[x;y]selectfrom x where a within y}")q)unshow get{select from x where a within y}(0x0ba0a178a20a040005;,`x;`symbol$();,`;0b;,(within;`a;`y);?;"{selectfrom x where a within y}")note the differences in element one (args) of the function objectsanother workaround:q){y;select from x where a within y}[t;3 5]a b----------3 6.2542564 3.6673165 9.844223the same is true of y (and z) in the select clauseq)unshow{select a+y from x}[t;3]'rankq){[x;y]select a+y from x}[t;3]a--3456789101112and probably in the by clause too, tho i can't think of a test off thetop of my head