# Functional upsert

**URL:** <https://forum.kx.com/t/functional-upsert/9452>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [February 6, 2015, 3:00am UTC](https://forum.kx.com/t/functional-upsert/9452 "2015-02-06T03:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samsogade](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samsogade](https://forum.kx.com/u/samsogade)\
**Post date:** [February 6, 2015, 3:00am UTC](https://forum.kx.com/t/functional-upsert/9452/1 "2015-02-06T03:00:00Z")

</div>

I’m having some trouble translating an upset into functional form:

q)ticks:([sym:()] price:(); size:(); ae:())

q)parse “`ticks upsert (`AAPL;100.0;10;1b)”

.[;();,;]

,`ticks

(enlist;,`AAPL;100f;10;1b)

understand line #2 and #3 are first and second argument, respectively. How would these arguments be applied to the dot (amend)? Guess I don’t understand the amend function correctly.

Thanks.

---

<div class="post-metadata">

**Author:** ![Himanshu1](https://avatars.discourse-cdn.com/v4/letter/h/7cd45c/32.png) [@Himanshu1](https://forum.kx.com/u/Himanshu1)\
**Post date:** [February 6, 2015, 3:25am UTC](https://forum.kx.com/t/functional-upsert/9452/2 "2015-02-06T03:25:00Z")

</div>

Here you go:

q).[ticks;();,;(`AAPL;100f;10;1b)]

sym &nbsp;price size ae

* * *

AAPL 100 &nbsp; 10 &nbsp; 1

---

<div class="post-metadata">

**Author:** ![samsogade](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@samsogade](https://forum.kx.com/u/samsogade)\
**Post date:** [February 6, 2015, 1:57pm UTC](https://forum.kx.com/t/functional-upsert/9452/3 "2015-02-06T13:57:00Z")

</div>

Thank you Himanshu.

Guess I was confused over the 3rd argument (,) - is it interpreted as join? I was replacing it with enlist.

---

<div class="post-metadata">

**Author:** ![Himanshu1](https://avatars.discourse-cdn.com/v4/letter/h/7cd45c/32.png) [@Himanshu1](https://forum.kx.com/u/Himanshu1)\
**Post date:** [February 6, 2015, 2:55pm UTC](https://forum.kx.com/t/functional-upsert/9452/4 "2015-02-06T14:55:00Z")

</div>

You’re welcome!

@ and . and not like functional forms of select/update (? and !) where the parameters are t,c,b,a.&nbsp;  
@ and . have different parameters.&nbsp;

You can read about them here:

[http://code.kx.com/wiki/JB:QforMortals2/functions#Functional\_Forms\_of\_Amend](http://code.kx.com/wiki/JB:QforMortals2/functions#Functional%5C_Forms%5C_of%5C_Amend)

Basically,&nbsp;

first parameter (`ticks) is the table/list/dictionary,&nbsp;

second parameter () is a subset of that data set that you want to modify,&nbsp;

third parameter (,) is the function/operation you want to apply to that subset and&nbsp;

fourth parameter (`AAPL;100f;10;1b) is any argument for the function/operation passed as the third argument.
