I wrote
> > I also wonder if there is any difference between (2"0)and (2&p.) .

Raul Miller <[email protected]> answered:
>    8 8 ] .(2"0) 9 9
> 2 2
>    8 8 ] .(2&p.) 9 9
> 2 2
> 2 2

Thank you very much for the answer, Raul.

I am having a hard time trying to understand what is going on here. 

We are considering the constant function f(x)=2, implemented in two ways:
   f1 =. 2"0
   f2 =. 2&p.

Considered monadic verbs there seems to be no difference, but somehow (f1) and 
(f2) are also dyadic verbs.
   ]n=.i.5
0 1 2 3 4
   f1 n NB. correct monadic
2 2 2 2 2
   f2 n NB. correct monadic
2 2 2 2 2
   n f1 n NB. dyadic, no harm done
2 2 2 2 2
   n f2 n NB. dyadic, unexpected result. 
0 1 2 3 4
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2

   0 8 f1 9 9 9 NB. What is the use of the left argument anyway?
|length error: f1
|   0 8     f1 9 9 9

   0 8 f2 9 9 9 NB. zero seems to be special
9 9 9
2 2 2
   0 f2 9 NB. Why not 2 ?
9

I could not predict this behaviour of dyadic (2"0) and (2&p.) from the 
dictionary descriptions of (") and (p.).




      Find din nye laptop på kelkoo.dk. Se de gode tilbud her - 
http://dk.yahoo.com/r/pat/mm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to