http://www.jsoftware.com/jwiki/Essays/Boxed_Array_Display#HTML
now incorporates the HTML ideas described by Ric Sherlock
and are much simpler as a consequence.

There is still an infelicity as demonstrated by  thh 5!:2 <'assert' .
The code assumes that each horizontal line takes the same 
vertical space as a line of text.  This assumption is incorrect 
(a horizontal line takes much less space than a line of text), 
but I don't know what to do about it.  Perhaps nothing needs
to be done (i.e. perhaps it's good enough).



----- Original Message -----
From: Roger Hui <[email protected]>
Date: Tuesday, March 30, 2010 8:33
Subject: Re: [Jbeta] displaying boxed array in html
To: Beta forum <[email protected]>

> Thanks.  I see that the code below has some obvious 
> problems (e.g. the display of <"0 i.2 2 3 4 has the 0 1 2 ...
> going down then across, rather than across then down,
> as in the ": display).  But the HTML ideas do work 
> (border collapse, vertical alignment, etc.). 
> I will incorporate these ideas with my code.
> 
> I should point out that in this case I favor shorter code
> rather than shorter output.  So for example I am not
> too bothered by an extra layer of <table>...</table>.
> 
> 
> 
> ----- Original Message -----
> From: "Sherlock, Ric" <[email protected]>
> Date: Tuesday, March 30, 2010 4:38
> Subject: Re: [Jbeta] displaying boxed array in html
> To: Beta forum <[email protected]>
> 
> > > > Roger Hui wrote:
> > > > For the 5 examples I listed, can you produce programmatically
> > > > (not by hand) results that "look like" what the monad ": 
> produces?> > > Also, can all the lines have the same width?  
> Currently 
> > the interior
> > > > lines are thicker than the external ones.
> > > >
> > > > Otherwise it looks promising.
> >  
> > > I wrote:
> > > 
> > > Next step is to handle the nested examples as well.
> > > 
> > 
> > The following seems to work ok. The obvious exception being 
> that 
> > the alignment of row heights between planes is not achieved.
> > 
> > Note 'tests'
> > JARRAYSTYLE, dispArray i.2 2 3 4
> > JARRAYSTYLE, dispArray <"0 i.2 2 3 4
> > JARRAYSTYLE, dispArray 5!:2 <'assert'
> > JARRAYSTYLE, dispArray 2 3 4 $ i.&.> i.7
> > JARRAYSTYLE, dispArray x=: 2 2 3 $ (i.&.>i.6),<<2 
> 5$'abcdefghij'> )
> > 
> > require 'strings'
> > 
> > sh     =: (*/@}: , {:)@(1&,)@$ ($,) ]
> > rows   =: */\...@}:@$
> > bl     =: }.@(,&0)@(+/)@(0&=)@(|/ i...@{.@(,&1))
> > mask   =: 1&,. #&, ,.&0@>:@i...@#
> > mat    =: m...@bl@rows { ' ' , sh
> > 
> > JARRAYSTYLE=: 0 : 0
> > <style type="text/css">
> > .jarray {font-family:monospace;}
> > table.jarray {border-collapse:collapse;}
> > table.jarray td {border:solid black thin;vertical-align: 
> > top;padding:0.3em;}table.jarray tr.spacer td {border:none;}
> > </style>
> > )
> > 
> > dispSimpArray=: 3 : 0
> >   t=. mat ": y
> >   t=. _4}., t ,"1 '<br>'
> >   t=. t rplc ' ';' '
> >   '<div class="jarray">',t,'</div>'
> > )
> > 
> > dispBoxArray=: 3 : 0
> >   if. 0 = L. y do. y return. end.
> >   t=. dispBoxArray^:(0 < L.)&.> y
> >   cols=. {:$ t
> >   t=. (,&.>/)"1 ('<td>', ,&'</td>') &.> t
> >   t=. (,&.>/)"1 ('<tr>', ,&'</tr>') &.> t
> >   s=. '<tr class="spacer">',(cols ((* #) $ 
> > ])'<td> </td>'),'</tr>'  while. 0 < #$ t do.
> >     t=. ([ , s , ])&.>/"1 t
> >     s=. s,s
> >   end.
> >   '<table 
> > class="jarray"><tbody>',(>t),'</tbody></table>')
> > 
> > dispArray=: [: dispBoxArray dispSimpArray L:0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to