Fundamental Capstone query

in the fundamental capstone question 1.2 im asked to write a function to create a dictionary which contains the number of records in each table in the database that ive loaded in previously. i began by removing the attribute from the list of tables and then creating my dictionary like this.

a:#[`;tables];

a!count each value each a

 

this works perfect however when i try to put the above inside a parameterless function it doesnt work. im working in kx developer. what mistake am i making?



Not been able to replicate this in a q session. 

 

q)t:(a:xyz;b:1 2 3) q)u:([]a:10?3;b:10?1000) q){x!count each value each x}tables / unary function t| 3 u| 10 q)f:{a!count each value each a:tables} / nullary function q)f t| 3 u| 10

 

 “Doesn’t work” rarely does it as a problem report. What did you see?

FWIW there is a tacit solution. Use Compose to bind count and value and project each onto them as its left argument: ('[count;value])each. The projection is a unary; you can use the Zen monks idiom to both apply and not-apply it to the list of tables. Make a dictionary of the resulting 2-list. 

 

q)1 ((‘[count;value])each)\ tables / Zen monks t u 3 10 q).[!] 1 ((’[count;value])each)\ tables / dictionary t| 3 u| 10