Slight (?) difference between your required output and what I produced.

   (< (;:'345*_2+;+/@:') , (<;:'+/%#') , ;:'*]') ,;: '-''hello''"_,<.'
+-----------------------------------+-+-------+-+-+-+--+
|+---+-+--+-+-+-+-+--+---------+-+-+|-|'hello'|"|_|,|<.|
||345|*|_2|+|;|+|/|@:|+-+-+-+-+|*|]|| |       | | | |  |
||   | |  | | | | |  ||+|/|%|#|| | || |       | | | |  |
||   | |  | | | | |  |+-+-+-+-+| | || |       | | | |  |
|+---+-+--+-+-+-+-+--+---------+-+-+| |       | | | |  |
+-----------------------------------+-+-------+-+-+-+--+

   (;&,/'()') N2Btc NEST
+-------------------+-----------+-----+-+-------+-+-+-+--+
|+---+-+--+-+-+-+--+|+---------+|+-+-+|-|'hello'|"|_|,|<.|
||345|*|_2|+|+|/|@:|||+-+-+-+-+|||*|]|| |       | | | |  |
|+---+-+--+-+-+-+--+|||+|/|%|#|||+-+-+| |       | | | |  |
|                   ||+-+-+-+-+||     | |       | | | |  |
|                   |+---------+|     | |       | | | |  |
+-------------------+-----------+-----+-+-------+-+-+-+--+


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens R.E. Boss
> Verzonden: dinsdag 25 augustus 2009 16:49
> Aan: 'Programming forum'
> Onderwerp: Re: [Jprogramming] Recursive nesting, avoiding recursion
> 
> > -----Oorspronkelijk bericht-----
> > Van: [email protected] [mailto:programming-
> > [email protected]] Namens Dan Bron
> > Verzonden: maandag 24 augustus 2009 21:56
> > Aan: Programming forum
> > Onderwerp: Re: [Jprogramming] Recursive nesting, avoiding recursion
> >
> > R E Boss wrote:
> > >  Had a very short look, but perhaps here
> > >  http://jsoftware.com/pipermail/programming/2009-June/014985.html
> >
> > This is an interesting approach.  I especially like your  (I.x) </. y
> > phrase.
> >
> > Do you think you can adapt it to produce  BOX  from  NEST  as below?
> >
> > -Dan
> 
> 
> BrLvl=: 1 _1 0 +/\@:{~ i.             NB. BracketLevel
> 
>    (;&,/'()') BrLvl NEST
> 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 1 0 0 0 0 0 0 0
> 
> 
> Unlike you and (some) others I am no longer 'in tacitness', so first the
> explicit version:
> 
> N2B=: 4 : 0           NB. Nested to Boxed
> z=. 1 _1 0 {~ x i. y
> ;<@]^:[&.>/"1 (z <;._1 y) ,.~ (z=. 1 (0)} |z) <@{.;.1 +/\ z
> )
> 
>    (;&,/'()') N2B NEST
> +-------------------+-----------+-----+-+-------+-+-+-+--+
> |+---+-+--+-+-+-+--+|+---------+|+-+-+|-|'hello'|"|_|,|<.|
> ||345|*|_2|+|+|/|@:|||+-+-+-+-+|||*|]|| |       | | | |  |
> |+---+-+--+-+-+-+--+|||+|/|%|#|||+-+-+| |       | | | |  |
> |                   ||+-+-+-+-+||     | |       | | | |  |
> |                   |+---------+|     | |       | | | |  |
> +-------------------+-----------+-----+-+-------+-+-+-+--+
> 
> 
> But to test my tacit fluency, also this version:
> 
> N2Btc=: [:; [: <@]^:[&.>/"1 ] (<@{.;.1~/@] ,. (<;._1~ {:)) [:(+/\ ,: 1
> (0)}
> |) 1 _1 0 {~ i.
> 
>    (;&,/'()') N2Btc NEST
> +-------------------+-----------+-----+-+-------+-+-+-+--+
> |+---+-+--+-+-+-+--+|+---------+|+-+-+|-|'hello'|"|_|,|<.|
> ||345|*|_2|+|+|/|@:|||+-+-+-+-+|||*|]|| |       | | | |  |
> |+---+-+--+-+-+-+--+|||+|/|%|#|||+-+-+| |       | | | |  |
> |                   ||+-+-+-+-+||     | |       | | | |  |
> |                   |+---------+|     | |       | | | |  |
> +-------------------+-----------+-----+-+-------+-+-+-+--+
> 
> 
> Just for fun:  (NB. wrap around)
> 
>    (;&,/'()') N2Btc ;:5!:5 <'N2Btc'
> +-+--+-+-+-+--+-+--+-+-+-+-+-+------------------------+----------------++-
> -+
> ----------+-----+-------+------+-+-+--+
> |;|[:|<|@|]|^:|[|&.|>|/|"|1|]|+-+-+--+--+-+-+-+-+-+--+|+--------------
> +||[:|
> +-+-+-+--+|+---+|+-+-+-+|1 _1 0|{|~|i.|
> | |  | | | |  | |  | | | | | ||<|@|{.|;.|1|~|/|@|]|,.|||+-+--+--+-+--+|||
> ||+|/|\|,:|||+-+|||0|}||||      | | |  |
> | |  | | | |  | |  | | | | | |+-+-+--+--+-+-+-+-+-+--+|||<|;.|_1|~|{:||||
> |+-+-+-+--+|||1|||+-+-+-+|      | | |  |
> | |  | | | |  | |  | | | | | |                        ||+-+--+--+-+--+|||
> |
> ||+-+||       |      | | |  |
> | |  | | | |  | |  | | | | | |                        |+--------------+||
> |
> |+---+|       |      | | |  |
> +-+--+-+-+-+--+-+--+-+-+-+-+-+------------------------+----------------++-
> -+
> ----------+-----+-------+------+-+-+--+
> 
> Left as an exercise for the reader is to get rid of empty boxes: (NB. wrap
> around)
> 
>    (;&,/'()') N2Btc 20{.;:5!:6 <'N2Btc'
> +-+----+--+----+------+--------+-----------------+--------------+---------
> --
> -+-------+
> |;|+--+|++|+--+|+----+|+------+|+---------------+|+------------+|+--------
> --
> +|+-----+|
> |
> ||[:||||||++|||+--+|||+----+|||+-------------+|||+----------+|||+--------
> +||
> |+---+||
> |
> |+--+|++||||||||++|||||+--+|||||+-----------+|||||+--------+|||||+------
> +|||
> ||+-+|||
> | |    |
> ||++||||||||||||++|||||||+---------+|||||||+------+|||||||+--+-
> +|||||||/||||
> | |    |
> |+--+|||++||||||||||||||||+-------+|||||||||+--+-+|||||||||&.|>|||||||+-
> +|||
> | |    |  |
> ||+--+|||||++|||||||||+-+-+-+|||||||||||^:|[|||||||||+--+-+|||||+---+||
> | |    |  |
> |+----+|||+--+|||||||||<|@|]|||||||||||+--+-+|||||||+------+|||+-----+|
> | |    |  |    |
> ||+----+|||||||+-+-+-+|||||||||+------+|||||+--------+||       |
> | |    |  |    |
> |+------+|||||+-------+|||||||+--------+|||+----------+|       |
> | |    |  |    |      |        ||||+---------+|||||+----------+||
> |       |
> | |    |  |    |      |        |||+-----------+|||+------------+|
> |       |
> | |    |  |    |      |        ||+-------------+||              |
> |       |
> | |    |  |    |      |        |+---------------+|              |
> |       |
> +-+----+--+----+------+--------+-----------------+--------------+---------
> --
> -+-------+
> 
> 
> R.E. Boss
> 
> ----------------------------------------------------------------------
> 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