AFAIU you can't count the number of linear calls this way. It doesn't
count the first time.

n=:0

   v/9
9
   n
0


Hallo Viktor Cerovski, je schreef op 20-02-10 01:36:
>
> Zsbán Ambrus wrote:
>   
>> Dear Jsoftware,
>>
>> Is there any chance that a future J version would optimize the monad
>> u/\. for any verb u to make only linear number of calls to u instead
>> of quadratic?
>>
>> I know this would break the case when u has side effects, but I still
>> believe this would be a useful feature (if documented), for it would
>> help in lots of cases but break only little code.
>>
>> As a model, for any verb u and noun y, (u/\. y) could be executed as
>> if it was (>,(];~>@[u>@{...@])/<"_1 y).
>>
>> Ambrus
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>>     
> Linear number of calls can be also checked out like this:
>
>    v =: dyad : 0
>  n=:n+1
>  x + y
> )
>    n=:0
>    v/\.i.10
> 45 45 44 42 39 35 30 24 17 9
>    n
> 9
>    +/\.i.10
> 45 45 44 42 39 35 30 24 17 9
>
> DoJ says: "u\.y has #y items resulting from applying u 
> to suffixes of y ,[...]".  If we stick to this definition, what should 
> be the value of n in the above example?
>   

-- 
Met vriendelijke groet,
=@@i

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to