Hi Ric, Thanks. I'm actually reading Chapter 6 of Learning J right now then proceed to the link you gave me for reading tacit verbs.
It actually makes me wonder ... if converting my for_ loops to tacit make it run faster? I have a lot of for_ loops and I was having trouble with one that take around 30 minutes to finish (5 levels deep). r/alex -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sherlock, Ric Sent: Thursday, September 18, 2008 6:52 PM To: Programming forum Subject: RE: [Jprogramming] RE: Applying Amend on each row ---Alex Rufon wrote: > I have to admit that I'm new to this type of programming with J so > please be patient with my questions. > 1. I initially tried doing a tacit definition of > cmp0=: I. 0 = > |syntax error > | cmp0=: I.0= > So why does the following script not fail anymore (although it doesn't > work)? > cmp0=: I. 0 =, The tacit: x (I. 0 =) y Is the same as explicit: (x I. y) 0 (x = y) Which you will recognise as a syntax error. The tacit x (I. 0 = ,) y Is parsed as a 2-verb hook x (I. (0 = ,)) y The first verb (0 = ,) is a noun followed by 2 verbs and so (according to the dictionary page you quote below) is equivalent to (0"_ = ,) so we have: x (I. (0"_ = ,)) y Which is the same as the explicit x I. (0"_ y) = (, y) 0"_ is a verb that will return 0 for any x & y. So this is the same as: x I. 0 = , y Not what you want! > 2. M is 2 dimension matrix. The result of ([: I. 0 = ,@]) is 6 and 8. > The code proceeded to amend the data as if it was a vector!!! If I try > to do that manually, I'll get errors. Why? This is due to the different forms of amend m} and u} where m is a noun and u is a verb. The Learning J chapter I referenced explains this in more detail. > 3. This is the first time I use [: symbol. I looked it up in the help > file and my brains threw a breaker after reading this : > "For example, 5(+*-)3 is (5+3)*(5-3). If f is a cap ([:) the capped > branch simplifies the forks to g h y and g x h y . The train N g h (a > noun followed by two verbs) is equivalent to N"_ g h . The > ranks of the > hook and fork are infinite." > I would appreciate it if somebody can provide a better explanation ... > please. :) The key bit here is "If f is a cap ([:) the capped branch simplifies the forks to g h y and g x h y" This is saying that if you have the following tacit ([: g h) y NB. g and h are verbs It is the same as the explicit g h y And x ([: g h) y Is the same as g x h y The tacit expression: x ([: I. 0 = ,@]) y Is the same as I. x (0 = ,@]) y Which is equivalent to I. 0 = x ,@] y And x [EMAIL PROTECTED] y is the same as: f x g y so we can rewrite as: I. 0 = , x ] y And x ] y is just y, leaving us with: I. 0 = , y You might want to check out this wiki page: http://www.jsoftware.com/jwiki/Guides/Reading_Tacit_Verbs ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
