It works ok for me:

   print=: smoutput  NB. --unless you actually want hardcopy!
   humbug 0
We wish you a Merry Christmas
We wish you a Merry Christmas
We wish you a Merry Christmas
And a Happy New Year!

Running a verb always needs an argument (in this case 0) even if the
verb doesn't use it.

And if you define your verb using (4 : 0) instead of (3 : 0) then it
needs 2 arguments: one on either side of the word: 'humbug'. Otherwise
you get:

|domain error: humbug

An expression in J can evaluate to a verb as well as a noun. If you
simply type in:
   humbug
this evaluates to a verb, which outputs the verb definition to the IJX
window. My guess is, that's what you did.


On Fri, Jun 29, 2012 at 7:43 AM, Charles Pechacek
<cfp424f...@hotmail.com> wrote:
>
>
> Hello
> I have been trying to get a handle on the 'for.' control command, using a 
> little program taken from a
> Pascal book, of which I have written a script as follows:
> load 'print'
> humbug=: 3 : 0
> for. >: i.3 do.
> print 'We wish you a Merry Christmas'
> end.
> print 'And a Happy New Year!'
> )
> Here are the instructions, which I think are relevant, taken from the last 
> example of section 12.3.7 of 'Learning J':
> Another variation is the pattern for. A do. B end. in which block B is 
> executed as many times as there are items of A.
> However, when I run this program, all that results is a copy of the code.
> What am I doing wrong?
> Thanks in advance.
> Charles
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to