Dictionaries · Converting Dictionaries to Tables · Practice Question
Conforming Dictionaries
Question
What are conforming dictionaries?
Given the following dictionaries:
A:`a`b!10 20
B:`a`b!20 30Explain why:
(A;B)produces a table.
Also explain why the following does not produce a table:
A:`a`b!10 20
B:`b`a!20 30
(A;B)Solution
A:`a`b!10 20
B:`a`b!20 30
(A;B)a b
-----
10 20
20 30A and B conform — same keys, `a`b, in the same order — so q promotes the list to a table (type (A;B) is 98h).
Alternative Solution
A:`a`b!10 20
B:`b`a!20 30
(A;B)`a`b!10 20
`b`a!20 30Here the key names match but the order doesn't (`a`b vs `b`a), so the dictionaries don't conform — (A;B) stays a plain 2-item list of dictionaries.
Explanation
The only requirement for auto-promotion is matching keys in matching order — value types are irrelevant. E.g. B:`a`b!("hjk";"ghj") still conforms with A:`a`b!10 20, producing a table whose columns a and b are general (mixed) lists.