# dictionaries as functions

**URL:** <https://forum.kx.com/t/dictionaries-as-functions/14102>\
**Category:** Community Support\
**Tags:** imported, kdb-and-q\
**Created:** [December 6, 2024, 4:25pm UTC](https://forum.kx.com/t/dictionaries-as-functions/14102 "2024-12-06T16:25:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dang30.swati](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/dang30.swati/32/128_2.png) [@dang30.swati](https://forum.kx.com/u/dang30.swati)\
**Post date:** [December 6, 2024, 4:25pm UTC](https://forum.kx.com/t/dictionaries-as-functions/14102/1 "2024-12-06T16:25:36Z")

</div>

[https://learninghub.kx.com/forums/topic/dictionaries-as-functions](https://learninghub.kx.com/forums/topic/dictionaries-as-functions)

I have 2 functions defined in the test namespace:  
.test.ex.t1:{[data] xxx; xxx;};  
.test.ex.t2:{[data] xxx; xxx;};  
  
Then, I want call these functions as below:  
.test.ex .' ((`t1;data);(`t2;data))  
but I run into a length error - what's the correct syntax?

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [December 6, 2024, 4:43pm UTC](https://forum.kx.com/t/dictionaries-as-functions/14102/2 "2024-12-06T16:43:39Z")

</div>

/: each-right is what you want&nbsp;[https://code.kx.com/q/ref/maps/#each-left-and-each-right&nbsp;](https://code.kx.com/q/ref/maps/#each-left-and-each-right&nbsp;)

```
q).test.ex.t1:{[data] data};

q).test.ex.t2:{[data] data};

q).test.ex ./:((`t1;1);(`t2;1))

1 1
```

---

<div class="post-metadata">

**Author:** ![unterrainer\_ale](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/unterrainer_ale/32/108_2.png) [@unterrainer\_ale](https://forum.kx.com/u/unterrainer_ale)\
**Post date:** [December 6, 2024, 4:45pm UTC](https://forum.kx.com/t/dictionaries-as-functions/14102/3 "2024-12-06T16:45:35Z")

</div>

If you look at your dictionary you can see that your key is a symbol atom, so you have to index by a symbol. Once you have done that, you can pass the value as parameter. This syntax should work

```
// Your dictionary

q).test.ex

| ::

t1| {[x] x}

t2| {[x] x}

q).test.ex[`t1`t2]@'3 4

3 4
```
