Randy wrote:
>  Is your definition of ts, which seems to ignore the left argument when 
>  used dyadically, useful for some other purpose which I don't happen to see?

The definition of  ts  works both monadically and dyadically.  The verbs give 
(respectively) measurements of time and space consumed by the J sentence that 
is its right argument.  Mondically,  ts  executes the sentence  y  once and 
reports the time and space consumed.  Dyadically, it executes the sentence  x  
times and reports the average time and space used per execution.  That is,  ts 
y  is shorthand for  1 ts y  .

Your analysis is partially correct and partially incorrect.  You are incorrect 
that the dyad  ts  ignores its left argument.  You are correct that part of the 
definition of  ts  relies only on the right argument.  Specifically, the result 
of  6!:2  depends on both arguments, but  7!:2@:]  ignores the left argument (I 
don't know why the definition was given with  &]  instead of  @:]  ). 

This is because  6!:2  has a dyadic definition, but  7!:2  does not.  That is,  
 x 6!:2 y  executes  y  (the J sentence)  x  times, and reports the average 
execution time, but  x 7!:2 y  has no definition (makes no sense; is an error). 
 I do not know the rationale behind this difference, but I speculate that the 
space consumed by an expression is more or less fixed, whereas the time is 
subject to the vagaries of operating system, task scheduling, CPU pipelining, 
etc.

I do not agree with your earlier lottery analogy, and this is a good example of 
why not.  If you'd looked up  6!:2  and 7!:2  you would know what the dyad  ts  
would do.  That is, if you (can read J well enough to) know that the expression 
 x (f g h@:]) y  will yield  (x f y) h g y  (and that  x ts y  is an instance 
of such an expression).  But, even if you didn't, and you read the definitions 
of  6!:2  and 7!:2  , the fact that  6!:2  has a dyadic definition but  7!:2  
does not would lead you to suspect the truth (or at least lead you to 
investigate further).  By the way, a version of  ts  that really would ignore 
its left argument would be  ts =: (6!:2 , 7!:2)@:]  .

The thread to which you posted the lottery analogy provided another 
counterexample to it.  Alex was using  8!:2  .  That verb is documented on the  
8!:n  page, along with  8!:0  and 8!:1  .  The only difference between these 
verbs, and the only reason for having three instead of one, are their 
respective ranks and the style by which they box their results (as described on 
the page in question).  The only issue Alex had using  8!:2  was its rank and 
the style by which it boxed its result.  

When looking for more effective ways to use a verb, or in trying to resolve 
issues encountered with a verb's use, it is reasonable to read the page 
dedicated to that verb.  In this case, I would have read the page dedicated to 
describing  8!:n  (where  8!:2  is documented) and in doing so I would have 
encountered  8!:0  , which provides exactly the results desired.  I would not, 
for example, have opened the Vocabulary page and randomly selected a primitive 
to read about (e.g.  \.  ).  So your lottery analogy doesn't apply.*

-Dan

 PS:  *  Unless lotteries are fixed.  But I wouldn't be surprised if this were 
true, given the stakes.

PPS:  In  x 6!:2 y  I assumed  x  would be constrained to the positive 
integers.  But I tried  0  (with the expected result)  and negative numbers 
(with unexpected results).

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

Reply via email to