hmmm .. oh yeh - i could have timed it too.

so, anyway, i was wrong to suspect [v^:(>:i.n) N] of being
a wasteful way of creating a list of results
.. that's great.

On 2011-07-11 18:03, Roger Hui wrote:
> There a few ways for you to find out:
>
>     f=: 3 : 'y [ smoutput y'
>     f^:1 2 3 ] 7
> 7
> 7
> 7
> 7 7 7
>
>     count=: 0
>     g=: 3 : 'y [ count=:>:count'
>     g^:(4 1 2) 7
> 7 7 7
>     count
> 4
>
> i.e. What you hoped for is true, "the second".
>
>
>
> ----- Original Message -----
> From: mijj<[email protected]>
> Date: Monday, July 11, 2011 9:46
> Subject: [Jprogramming] total number of invocations of  v in v^:(1 2)
> To: Programming forum<[email protected]>
>
>> how many times would the verb [v] be invoked in the following:
>>
>> v^:(1 2)
>>
>> would it be:
>>      once for the [1], and then twice for the [2].
>>      = 3 in total
>> or:
>>      the interpreter checks the numbers for [^:]
>> and works to
>>      minimise number of invocations, so makes use
>> of previous results.
>>      so its once for the [1] and an additional one
>> for the [2]
>>      = 2 in total.
>>      (if that's the case, then would it still be
>> so if the expression
>>      was [v^:(2 1)] ?)
>> ?
>>
>> i feel it's probably the first, but hope it's the second.
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to