# Fundamental Capstone query

**URL:** <https://forum.kx.com/t/fundamental-capstone-query/12499>\
**Category:** Academy Support\
**Created:** [April 19, 2022, 12:11pm UTC](https://forum.kx.com/t/fundamental-capstone-query/12499 "2022-04-19T12:11:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![conorn\_71](https://avatars.discourse-cdn.com/v4/letter/c/97f17d/32.png) [@conorn\_71](https://forum.kx.com/u/conorn_71)\
**Post date:** [April 19, 2022, 12:11pm UTC](https://forum.kx.com/t/fundamental-capstone-query/12499/1 "2022-04-19T12:11:00Z")

</div>

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

&nbsp;

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?

---

<div class="post-metadata">

**Author:** ![SJT1](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@SJT1](https://forum.kx.com/u/SJT1)\
**Post date:** [April 19, 2022, 3:33pm UTC](https://forum.kx.com/t/fundamental-capstone-query/12499/2 "2022-04-19T15:33:00Z")

</div>

> * * *
> 
> * * *

Not been able to replicate this in a q session.&nbsp;

&nbsp;

q)t:(a:`x`y`z;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

&nbsp;

&nbsp;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.&nbsp;

&nbsp;

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

&nbsp;
