2021.10.12 01:53 PM
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.
2021.10.12 06:45 PM - edited 2021.10.13 04:51 PM
Hi MEdan,
It depends if your variable is a dictionary or a table as this flips the indexes:
For example:
q)d:`name`iq!(`Dent`Beeblebrox`Prefect;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;]
`Dent`Beeblebrox`Prefect
q)d[`name;2]
`Prefect
q)t[2;]
name| `Prefect
iq | 126
q)t[;`name]
`Dent`Beeblebrox`Prefect
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
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.