doc error or product bug

Hi, KDB Folks

I found a problem running example from q function reference. Here is
from the reference

==============================================================================================
q)u:(“abcde”;10 2 -6;(2 3;`ab))
q)u?10 2 -6
1
q)u?“abcde”
0
However, if the right argument is a general list then items of the
left argument are matched with items of the right argument. For
example,

q)u?(2 3;ab) 3 3 In this case Find matches items of the left argument with 2 3 and ab , not (2 3;ab). In order to find (2 3;ab) it must be an item of
a list, as follows.

q)u?enlist(2 3;`ab)
2

I tried the example in kdb with version:
KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systems

q)u?enlist(2 3;`ab) / still gives 3 3 instead of 2
3 3

Is it a reference error or KDB bug?

Thanks

Documentation error

? is rank sensitive; x?y can’t deal with mixed rank x.
if rank x is n then x?y looks for objects of rank n-1.
e.g.
2 3?2 3#til 6  / looks for rank 0 objects
(0 1 2;4 5)?2 3#til 6 / looks for rank 1 objects

For the case you mention, a solution is

q)f:{where x~:y}
q)f[u;(2 3;`ab)]
,2

Thanks, Chuck.On Sep 21, 10:33?am, Charles Skelton <char…> wrote:> Documentation error>> ? is rank sensitive; x?y can’t deal with mixed rank x.> if rank x is n then x?y looks for objects of rank n-1.> e.g.> 2 3?2 3#til 6 ?/ looks for rank 0 objects> (0 1 2;4 5)?2 3#til 6 / looks for rank 1 objects>> For the case you mention, a solution is>> q)f:{where x~:y}> q)f[u;(2 3;ab)]&gt; ,2&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; On Wed, Sep 21, 2011 at 4:22 PM, dbtouch <dbto...> wrote:&gt; &gt; Hi, KDB Folks&gt;&gt; &gt; I found a problem running example from q function reference. Here is&gt; &gt; from the reference&gt;&gt; &gt; =========================================================================== ===================&gt; &gt; q)u:("abcde";10 2 -6;(2 3;ab))> > q)u?10 2 -6> > 1> > q)u?“abcde”> > 0> > However, if the right argument is a general list then items of the> > left argument are matched with items of the right argument. For> > example,>> > q)u?(2 3;ab)&gt; &gt; 3 3&gt; &gt; In this case Find matches items of the left argument with 2 3 and&gt; &gt; ab , not (2 3;ab). In order to find (2 3;ab) it must be an item of> > a list, as follows.>> > q)u?enlist(2 3;ab)&gt; &gt; 2&gt;&gt; &gt; =========================================================================== ===================&gt;&gt; &gt; I tried the example in kdb with version:&gt; &gt; KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systems&gt;&gt; &gt; q)u?enlist(2 3;ab) / still gives 3 3 instead of 2> > 3 3>> > Is it a reference error or KDB bug?>> > Thanks>> > –> >

Submitted via Google Groups</dbto…></char…>

Hi, ChuckI ran the function you gave and did not get 2q)f:{where x~\:y}q)f(u;(2 3;ab)){where x~:y}[((“abcde”;10 2 -6;(2 3;ab));(2 3;ab))]q)res:f(u;(2 3;ab))q)res{where x~\:y}[(("abcde";10 2 -6;(2 3;ab));(2 3;ab))]q)u"abcde"10 2 -6Could you take a look?On Sep 21, 10:33?am, Charles Skelton <char...> wrote:&gt; Documentation error&gt;&gt; ? is rank sensitive; x?y can't deal with mixed rank x.&gt; if rank x is n then x?y looks for objects of rank n-1.&gt; e.g.&gt; 2 3?2 3#til 6 ?/ looks for rank 0 objects&gt; (0 1 2;4 5)?2 3#til 6 / looks for rank 1 objects&gt;&gt; For the case you mention, a solution is&gt;&gt; q)f:{where x~\:y}&gt; q)f[u;(2 3;ab)]> ,2>>>>>>>> On Wed, Sep 21, 2011 at 4:22 PM, dbtouch <dbto…> wrote:> > Hi, KDB Folks>> > I found a problem running example from q function reference. Here is> > from the reference>> > =========================================================================== ===================> > q)u:(“abcde”;10 2 -6;(2 3;ab))&gt; &gt; q)u?10 2 -6&gt; &gt; 1&gt; &gt; q)u?"abcde"&gt; &gt; 0&gt; &gt; However, if the right argument is a general list then items of the&gt; &gt; left argument are matched with items of the right argument. For&gt; &gt; example,&gt;&gt; &gt; q)u?(2 3;ab)> > 3 3> > In this case Find matches items of the left argument with 2 3 and> > ab , not (2 3;ab). In order to find (2 3;ab) it must be an item of&gt; &gt; a list, as follows.&gt;&gt; &gt; q)u?enlist(2 3;ab)> > 2>> > =========================================================================== ===================>> > I tried the example in kdb with version:> > KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systems>> > q)u?enlist(2 3;`ab) / still gives 3 3 instead of 2> > 3 3>> > Is it a reference error or KDB bug?>> > Thanks>> > –> >

Submitted via Google Groups</dbto…></char…>

pay attention to brackets - () is not the same as

q)u:(“abcde”;10 2 -6;(2 3;`ab))

q)f:{where x~:y}

q)f[u;(2 3;`ab)]

,2

Oops…Thanks, Chuck.On Sep 21, 10:55?am, Charles Skelton <char…> wrote:> pay attention to brackets - () is not the same as >> q)u:(“abcde”;10 2 -6;(2 3;ab))&gt; q)f:{where x~\:y}&gt; q)f[u;(2 3;ab)]> ,2>>>>>>>> On Wed, Sep 21, 2011 at 4:49 PM, dbtouch <dbto…> wrote:>> > I ran the function you gave and did not get 2&gt;&gt; &gt; q)f:{where x~\:y}&gt; &gt; q)f(u;(2 3;ab))> > {where x~:y}[((“abcde”;10 2 -6;(2 3;ab));(2 3;ab))]> > q)res:f(u;(2 3;ab))&gt; &gt; q)res&gt; &gt; {where x~\:y}[(("abcde";10 2 -6;(2 3;ab));(2 3;ab))]&gt; &gt; q)u&gt; &gt; "abcde"&gt; &gt; 10 2 -6&gt;&gt; &gt; Could you take a look?&gt;&gt; &gt; On Sep 21, 10:33 am, Charles Skelton <char...> wrote:&gt; &gt; &gt; Documentation error&gt;&gt; &gt; &gt; ? is rank sensitive; x?y can't deal with mixed rank x.&gt; &gt; &gt; if rank x is n then x?y looks for objects of rank n-1.&gt; &gt; &gt; e.g.&gt; &gt; &gt; 2 3?2 3#til 6 ?/ looks for rank 0 objects&gt; &gt; &gt; (0 1 2;4 5)?2 3#til 6 / looks for rank 1 objects&gt;&gt; &gt; &gt; For the case you mention, a solution is&gt;&gt; &gt; &gt; q)f:{where x~\:y}&gt; &gt; &gt; q)f[u;(2 3;ab)]> > > ,2>> > > On Wed, Sep 21, 2011 at 4:22 PM, dbtouch <dbto…> wrote:> > > > Hi, KDB Folks>> > > > I found a problem running example from q function reference. Here is> > > > from the reference>> > ===========================================================================> > ===================> > > > q)u:(“abcde”;10 2 -6;(2 3;ab))&gt; &gt; &gt; &gt; q)u?10 2 -6&gt; &gt; &gt; &gt; 1&gt; &gt; &gt; &gt; q)u?"abcde"&gt; &gt; &gt; &gt; 0&gt; &gt; &gt; &gt; However, if the right argument is a general list then items of the&gt; &gt; &gt; &gt; left argument are matched with items of the right argument. For&gt; &gt; &gt; &gt; example,&gt;&gt; &gt; &gt; &gt; q)u?(2 3;ab)> > > > 3 3> > > > In this case Find matches items of the left argument with 2 3 and> > > > ab , not (2 3;ab). In order to find (2 3;ab) it must be an item of&gt; &gt; &gt; &gt; a list, as follows.&gt;&gt; &gt; &gt; &gt; q)u?enlist(2 3;ab)> > > > 2>> > ===========================================================================> > ===================>> > > > I tried the example in kdb with version:> > > > KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systems>> > > > q)u?enlist(2 3;`ab) / still gives 3 3 instead of 2> > > > 3 3>> > > > Is it a reference error or KDB bug?>> > > > Thanks</dbto…></char…></dbto…></char…>