retrieving values

I have a basic question:

a['name] vs b[val;'name]

Do I understand the first is a dictionary and I get the value that corresponds to a key “name”? But what data structure is the second? Is that a list? I am reading the code and trying to make sense of what I see.

 

Hi MEdan,

It depends if your variable is a dictionary or a table as this flips the indexes:

  • dictionary = d[key;index]
  • table = t[index;key]

For example:

 

q)d:nameiq!(DentBeeblebroxPrefect;98 42 126) q)d name| Dent Beeblebrox Prefect iq | 98 42 126 q)t:flip d q)t name iq -------------- Dent 98 Beeblebrox 42 Prefect 126 q)d[;2] name| Prefect iq | 126 q)d[name;] DentBeeblebroxPrefect q)d[name;2] Prefect q)t[2;] name| Prefect iq | 126 q)t[;name] DentBeeblebroxPrefect q)t[2;name] `Prefect

 

Passing only the symbol to either dictionary or table will return the associated values key/column:

 

q)d iq 98 42 126 q)t iq 98 42 126

 

Further reading:

Thanks for posting your query on the portal!

Kind regards,

David