# times or start value

**URL:** https://forum.kx.com/t/times-or-start-value/11940
**Category:** Community Support
**Tags:** kdb-and-q
**Created:** [August 16, 2019, 12:05am UTC](https://forum.kx.com/t/times-or-start-value/11940 "2019-08-16T00:05:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![leslie412i](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leslie412i](https://forum.kx.com/u/leslie412i)
#### Post date: [August 16, 2019, 12:05am UTC](https://forum.kx.com/t/times-or-start-value/11940/1 "2019-08-16T00:05:00Z")

</div>

hi guys.  
when I write&nbsp;

10 {x+y}/ 1 2

the 10 means it is the start value,

but when I write

10 { x, sum -2#x}/ 1 1

the 10 means 10 times

my question is how to tell when it means start value and when it means recursion times?&nbsp;&nbsp;

---

<div class="post-metadata">

### Author: ![User7](https://avatars.discourse-cdn.com/v4/letter/u/7ea924/32.png) [@User7](https://forum.kx.com/u/User7)
#### Post date: [August 16, 2019, 2:43am UTC](https://forum.kx.com/t/times-or-start-value/11940/2 "2019-08-16T02:43:00Z")

</div>

Hi Leslie,

It is determined by the rank (or valence) of the function in question. See here:&nbsp;https://code.kx.com/v2/ref/accumulators, specifically the section on unary and binary values.

{x+y} is binary, so the first evaluation applies to the left argument and the first item of the right argument (10 and 1) in your case. The result of this becomes the left argument of the next iteration, and the second item of the right hand argument becomes the new right argument.

{ x, sum -2#x} is unary. The 10 here is interpreted as do 10 times, however you are not strictly limited to a number on the left hand side here. You can use this syntax to repeat a function until it converges or while some condition is true. e.g:

({ x, sum -2#x}/)1 1 will run until the function converges. (This function will never converge however)

(20\>count@){ x, sum -2#x}/1 1 will run while the count of the output from the iteration in question is less than 20.

Regards,

Cillian

---

<div class="post-metadata">

### Author: ![Nick10](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@Nick10](https://forum.kx.com/u/Nick10)
#### Post date: [August 16, 2019, 4:26am UTC](https://forum.kx.com/t/times-or-start-value/11940/3 "2019-08-16T04:26:00Z")

</div>

using ‘/’(over) or ''(scan) with a monadic function (only including an ‘x’ parameter) with no numeric argument causes the function to iterate until convergence or until the original value is seen again.

the numeric argument tells it to run a specific number of times.

https://code.kx.com/v2/ref/over/

there is no need to do this with a variadic function because the length of the ‘y’, ‘z’, etc parameters control the number of iterations

---

<div class="post-metadata">

### Author: ![leslie412i](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leslie412i](https://forum.kx.com/u/leslie412i)
#### Post date: [August 16, 2019, 8:15am UTC](https://forum.kx.com/t/times-or-start-value/11940/4 "2019-08-16T08:15:00Z")

</div>

Hi Nick, thank you for your answer, I’m a newbie in q world, and tried to find out the answer for a long time.

---

<div class="post-metadata">

### Author: ![leslie412i](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leslie412i](https://forum.kx.com/u/leslie412i)
#### Post date: [August 16, 2019, 8:25am UTC](https://forum.kx.com/t/times-or-start-value/11940/5 "2019-08-16T08:25:00Z")

</div>

thanks!  
On Friday, August 16, 2019 at 12:26:52 PM UTC+9, Nick wrote:

> using ‘/’(over) or ''(scan) with a monadic function (only including an ‘x’ parameter) with no numeric argument causes the function to iterate until convergence or until the original value is seen again.
> 
> the numeric argument tells it to run a specific number of times.
> 
> https://code.kx.com/v2/ref/over/
> 
> there is no need to do this with a variadic function because the length of the ‘y’, ‘z’, etc parameters control the number of iterations
