Ric, That's a very interesting way at doing this, thanks very much. And thanks to everyone else who replied.
Just to elaborate a bit on what I am trying to do. I know something as (y*2)+y is trivial to the majority of this list so I thank everyone with replying with such good explanations. The actual expression I am trying to convert is slightly more complex but I didn't want to post - "how can I put this into J?" Instead I asked how to do such a simple operation so the knowledge from this email could be applied to help do what I want to do. As I am a big fan at solving problems myself Again thanks for answering, you guys really explain things thoroughly. On 9/11/08, Sherlock, Ric <[EMAIL PROTECTED]> wrote: > ---Raul Miller wrote: >> Ian Gorse wrote: >> > I am just trying to understand tacit verbs more, and I set myself >> > little algorithms to experiment in J. >> > I am just trying to understand the individual steps >> > required to make a tacit verb out of such simple calculations. >> >> My first step usually involves constructing an executable >> example of the >> phrase I want to work with, and some representative data. > > > I think that is good advice - get a working explicit version first. If you > can shorten it to one line you can also use 13 : 'my explicit sentence' to > find some where to start. > > As you get more familiar with tacit, you might want to start building them > from scratch. For me at least, this is not a linear process, but I'll try to > describe a general approach that (I think) I tend to follow. > > Put simply- I start at the end and work from the middle outwards (that > probably doesn't make much sense!). > What I mean is that I ask myself what the last operation will be, that verb > then becomes the middle verb of a 3 verb train or fork. Then I ask myself > what the left and right arguments need to be and work out what the last > operation needs to be for each of those, ... repeat until done. > > In the case of the explicit sentence: > (2*y) + y > > The last operation is the +, it therefore forms the middle tine of the main > fork. Its right argument is simply y or the right argument to the tacit > expression. A verb whose result is its right argument is ], so that becomes > right-hand tine of the main fork. The left argument to the middle tine needs > to be 2*y or 2 times the right argument to the tacit expression. The verb > for multiplication is * and I can make a new verb "2 times" by using & to > bond the 2 to * like this 2&* . I now have a fork that I think should do the > job so I don't have to continue the process. > > 2&* + ] > > With the box display form selected (Edit|Configure|Display) I can now check > that I do indeed have a fork. Type the proposed tacit verb in the session > and press Enter. > 2&* + ] > +-------+-+-+ > |+-+-+-+|+|]| > ||2|&|*|| | | > |+-+-+-+| | | > +-------+-+-+ > > Yep that looks like the fork I was trying to create. Next step, does it > work! To test I usually just surround the tacit with parentheses and then > add a right (and left) argument. > (2&* + ]) 10 > 30 > > Looks like it behaves as required. Now I can assign it to a name (don't need > the brackets anymore!): > > t=: 2&* + ] > t 10 > 30 > > Done. > > I find trying to explain something to someone else is a great way of > learning so thanks for indulging me!! > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
