On Tue, Sep 28, 2010 at 8:29 AM, Raul Miller <[email protected]> wrote:
> Factor=: monad define
>  tree=: ({.tree),(<1 0 2{tree),3}.tree
>  stack=: ({.stack),(classify '0'),3}.stack
> )

That is wrong.  I sent a fix to Dan (along with some stylistic changes),
but forgot to post it here:


Factor=: monad define
 tree=: ({.tree),(<2 A.0;1 2{tree),3}.tree
 stack=: ({.stack),(classify '0'),3}.stack
)

Note that I have overloaded the "end of stream" token.  I am
using an asterisk, which also happens to be the multiplication
symbol.  So I can use incorporate the first element when
I need to multiply.

But it's not the first element on the stack I need to use, it's
the first word that I need to use -- when I need to multiply,
that first word might not even be on the stack.

On a related note, when inspecting the partially completed
parse tree, I find this sentence to be useful:

   tree {L:0 _ words

Also useful, for my debugging, has been placing an smoutput
on the rule=: line in eval.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to