What are the values of r, c and m? But I think that the outer loop is being
run a number of times but the inner loop doesn't execute after the first
time through as c is never reset.

On Tue, Nov 1, 2011 at 6:54 PM, David Vaughan
<[email protected]>wrote:

> I was just writing a function that has a nested while loop, but it seems
> that the outer loop only executes once. I guess I must be missing something
> here.
>
> while. r<{.$m
> do.
>        while. c<{:$m
>        do.
>                m =. (((<r;c){m) + ((<r;c-1){m) <. ((<c;~r-1){m)) (<r;c) } m
>                c =. >:c
>        end.
>        r =. >:r
> end.
>
> Is there anything about that to suggest why the outer loop would only
> happen once?
>
> I outputted 'r' at the end of the function and it returned 4 when the verb
> was applied to i.4 4 (which is what you would expect it to be having
> finished its loop).
>
> Is there a way I can make my function output things part way through it?
> So I could see if I just have a logic error somewhere (which I cannot see
> but suspect is the issue) that causes the loop to appear to stop after the
> first iteration.
>
> Thanks.
> ----------------------------------------------------------------------
> 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