KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ kdb+/q Developer Lv2 – list indexing : exercise GList just before 4.2 for type

  • kdb+/q Developer Lv2 – list indexing : exercise GList just before 4.2 for type

    Posted by Ken__ on June 2, 2025 at 1:54 am

    Q1: why the type each GList not give -11h -7h -10h instead of -11 -7 -10h with only 3rd element with h for short value?


    Q2: the ipynb notebook seems to give results not following the command order,

    shouldn’t it be below if it respects the command query order?


    my query and expected results:

    type `a

    type 1

    type “b”

    -11h
    -7h
    -10h

    while the offical query and results look -11 -7 -10h so -11 is long -7 is long? or shorthand it is all short for h but just show for the last 3rd element?

    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    • This discussion was modified 1 day, 22 hours ago by  Ken__.
    Ken__ replied 4 hours, 46 minutes ago 2 Members · 2 Replies
  • 2 Replies
  • megan_mcp

    Administrator
    June 3, 2025 at 3:05 pm

    Hi @Ken__ 

    1. The h at the end of the list isn’t related to the last value. The h is placed at the end of the list to indicate this is a list of data type values.

    2. Do you mean why are the results showing the types before displaying the list even though the “show” query comes before the “type” query?

    • Ken__

      Member
      June 3, 2025 at 7:31 pm

      1. thanks prompt reply, but it’s a bit confusing indeed, so after your explanation it’s for the WHOLE LIST of same type value h, the type each in type each GList: (`a; 1 ; “b”) shows a list of value of each element data type and then an “h” char at the last to show these values of data type are of short type only.  <span style=”background-color: transparent; font-family: inherit; font-size: inherit;”>I thought as if it would show the same as the individual type command i.e.type `a

      type 1

      type “b” 

      will get same expected results from type each (`a;1;”b”) but it does not. 

      quite the opposite to what I thought would give the same result to individual type query to 3 value. I still cannot convey myself and dry run in brain when and why “type each” would show like this. 

      I can only think of a reasonable answer – type each would generate a list of same value, in this case it must be “h” for short

      2. yes your understanding to the question is correct, 

      the juypter notebook gives results of 

      type each GList first, 

      and then 

      show GList value

      however the command on notebook is 

      show GList and 2nd line the 

      type each GList

      why is that?

Log in to reply.