2
q)type variable

returns the type num of the arguement variable.

Is there a mapping that can produce the type char from a type num or do I have to create that dictionary myself?

Ideally something like

q)typeChar 1
i
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
nightTrevors
  • 639
  • 4
  • 11
  • 24

2 Answers2

4

You can use .Q.t.

q).Q.t abs type `test
"s"
q).Q.t abs type 5i
"i"

Edit: Or even better just use .Q.ty

This seems to return upper case for atoms and lower case for lists.

q).Q.ty `test
"S"
q).Q.ty `test`test2
"s"
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
jgleeson
  • 955
  • 5
  • 11
2

One option is to use 'key' function :

Reference: http://code.kx.com/q/ref/metadata/#key

Wiki says: Given a simple list, returns the name of the type as a symbol:

So you can make function like:

               q) tyeInChar:{key x,()}
               q) typeInChar  1i // output  `int
               q) typeInChar  "s"  //output `char
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Rahul
  • 3,914
  • 1
  • 14
  • 25