The problem is subtle. In a verb defined with 3 : '...', x is not the operand. y is.
So what you want is cnot_gate =: 3 : '(4 4 $ 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0) > (+/ . *) y' Normally your verb would have failed with a value error, indicating the x is undefined. However, somewhere in your session earlier, you said x =: ... and that set the value of the global name x. When you ran your cnot_gate verb, it was this old value of x that was used, producing a length error. Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Pascal Heus > Sent: Sunday, April 08, 2007 11:25 PM > To: Programming forum > Subject: [Jprogramming] Verb length error basic question > > Hi: > I'm mostly new to J. > Why do I get a "length error" when I define a verb as shown below (the > dot product of a 4x4 matrix with a 4x1 column vector) > > cnot_gate =: 3 : '(4 4 $ 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0) > (+/ . *) (x)' > and then executes > cnot_gate (,. 0 1 0 1) > |length error: cnot_gate > | (4 4$1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0) (+/ .*)(x) > > The direct call works correctly > (4 4 $ 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0) (+/ . *) (,. 0 1 0 1) > 0 > 1 > 1 > 0 > > > thanks > Pascal > > -- > A person starts to live when he can live outside himself. > - Albert Einstein > www.quotator.net > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
