Using a technique Hui applied in
http://www.jsoftware.com/pipermail/general/2008-July/032128.html
N2Ba=: 4 : 0
t=.((= * *...@]) >./) 1 _1 0 (+/\)@:{~ x i. y
z=. 1 4 5 e.~ 3 #.\ 1 0 , t
; <@}...@}:@]^:[ &.>/"1 (z <@{.;.1 t) ,. z <;.1 y
)
N2Batc=: [:; [: <@}...@}:@]^:[ &.>/"1 ] (<@{.;.1&>~/@] ,.(<;.1~ {:)) [: (;1 4
5 e.~ 3 #.\ 1 0 , ]) [: ((= * *...@]) >./) 1 _1 0 (+/\)@:{~ i.
NB. wrap around
(;&,/'()') N2Ba^:_ NEST
+---------------------------------+-+-------+-+-+-+--+
|+---+-+--+-+-+-+--+---------+-+-+|-|'hello'|"|_|,|<.|
||345|*|_2|+|+|/|@:|+-+-+-+-+|*|]|| | | | | | |
|| | | | | | | ||+|/|%|#|| | || | | | | | |
|| | | | | | | |+-+-+-+-+| | || | | | | | |
|+---+-+--+-+-+-+--+---------+-+-+| | | | | | |
+---------------------------------+-+-------+-+-+-+--+
BOX -: (;&,/'()') N2Ba^:_ NEST
1
BOX -: (;&,/'()') N2Batc^:_ NEST
1
(;&,/'()') N2Ba^:_ ;:5!:6<'N2Batc' NB. too big to display.
I do not see why
(5!:2 <'N2Batc') -: (;&,/'()') N2Ba^:_ ;:5!:6 <'N2Batc'
0
although they look the same.
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Dan Bron
> Verzonden: woensdag 26 augustus 2009 18:44
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Recursive nesting, avoiding recursion
>
> R. E. Boss wrote:
> > There is a remarkable difference between your NEST and BOX. Between the
> 2
> > plus signs in NEST you introduced a ';' in BOX:
>
> Just a typo. I composed the BOX expression by hand. The ; should've
> been elided:
>
> ] BOX =. (< (;:'345*_2++/@:') , (<;:'+/%#') ,
> ;:'*]'),;:'-''hello''"_,<.'
> +---------------------------------+-+-------+-+-+-+--+
> |+---+-+--+-+-+-+--+---------+-+-+|-|'hello'|"|_|,|<.|
> ||345|*|_2|+|+|/|@:|+-+-+-+-+|*|]|| | | | | | |
> || | | | | | | ||+|/|%|#|| | || | | | | | |
> || | | | | | | |+-+-+-+-+| | || | | | | | |
> |+---+-+--+-+-+-+--+---------+-+-+| | | | | | |
> +---------------------------------+-+-------+-+-+-+--+
>
> -Dan
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm