kdb one-item list not initializing

330 views Asked by At

I'm working through the Kx Technology Training Course, and there's a line that says

"Enlist applies to all data objects; the result for any data object is a one-item list whose item is that object. For example"

 enlist(2 5;3.5 10 12)
    ,(2 5;3.5 10 12)

This result is not a one dimensional list of floats. It is instead a 2-D list of count one who's sole element is a 1-D list of floats

but when I do the example exactly as is in Q I don't get that. I get

enlist(2 5;3.5 10 12)
2 5 3.5 10 12

so the following works, which I'd expect not to work given the explanation of the supposed structure:

enlist(2 5;3.5 10 12)+1
3 6 4.5 11 13

Whats going on?

1

There are 1 answers

1
WooiKent Lee On BEST ANSWER

It is just the way q console display the output. Your list is still enlisted.

If you do a simple count, you will notice the difference:

q)count (2 5;3.5 10 12)            / a list with 2 elements
2
q)count enlist (2 5;3.5 10 12)     / a list with 1 element
1

Or even a simple indexing:

q)(2 5;3.5 10 12)0                 / get the first element of the list
2 5
q)enlist[(2 5;3.5 10 12)]0         / get the first element of the enlisted list
2 5
3.5 10 12

Or you can switch to k console to see the result:

q)\
  (2 5;3.5 10 12)
(2 5;3.5 10 12)
  .q.enlist(2 5;3.5 10 12)
,(2 5;3.5 10 12)

Also + operator works through nested structure, that's why it won't error out.