Ooops, thank you Mike.  Another correction:
N  ( [ (] ;  bar2)  bar1 )&>/@]^:([ > 0 #@{:: ] )^:_ X0 ; Y0

    On Saturday, January 26, 2019, 11:25:10 a.m. EST, 'Mike Day' via 
Programming <programm...@jsoftware.com> wrote:  
 
 Pascal Jasmin’s power verb looks neat,  but I don’t think one pass does quite 
what Brian’s foo does:
one pass of foo modifies x with bar1 before changing y with bar2 using the new 
x.
eg, 
  x1 =. x  bar1 y
  y  =. x1 bar2 y
  x  =. x
I _think_ (bar1 ; bar2 ) &>/  x0;y0
returns 
(x0 bar1 y0); x0 bar2 y0
This might serve Brian’s purpose, of course!

Presumably a loopy version could be 
goo =: dyad define
while. N > #x do.
  y =. y bar2~ x =. x bar1 y
else.
  x
end.
)

Cheers,

Mike

Sent from my iPad

> On 26 Jan 2019, at 13:35, 'Pascal Jasmin' via Programming 
> <programm...@jsoftware.com> wrote:
> 
> How many times do you guess the function is recursing
> the power version  (with X0 Y0 initial values for x and y)
> 10  (bar1 ; bar2 )&>/^:([ > 0 #@{:: ] )^:_ X0 ; Y0
>    On Friday, January 25, 2019, 11:43:01 p.m. EST, Brian Schott 
><schott.br...@gmail.com> wrote:  
> 
> I am getting a stack error from code foo like that at the bottom of this
> post. First of all can I assume the error is due to the recursion? J says
> the stack error is occurring in the verb bar1 in my code.
> 
> If so, is it likely that I (or someone) can circumvent the stack error just
> by rewriting the verb foo using the Power conjunction ^: with a do while
> approach based on the N in the if. statement?
> 
> So, I am not just asking if the power conjunction is possible in this case,
> but also is there any likelihood that the stack error can be avoided.
> 
> If not, maybe someone can suggest another workaround.
> 
> N=: 10
> foo =: dyad define
> x                    NB. desired final result
> if. N>#x do.
> x =. x bar1 y
> y =. x bar2 y
> x foo y              NB. recursion
> end.
> )
> 
> -- 
> (B=) <-----my sig
> Brian Schott
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm  
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
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