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.



----- Original Message -----
From: "Sherlock, Ric" <[email protected]>
Date: Monday, March 29, 2010 18:46
Subject: Re: [Jbeta] displaying boxed array in html
To: Beta forum <[email protected]>

> I'm probably missing something, but it seems to me that a number 
> of the nested tables are redundant? 
> Couldn't a table cell <td></td> be thought of as a box? 
> Boxed planes could be separated rows without borders - that 
> would maintain vertical alignment of columns.
> 
> Below is an alternative HTML representation of the last example 
> that uses 2 rather than 16 tables:
> thh x=: 2 2 3 $ (i.&.>i.6),<<2 5$'abcdefghij'
> 
> <style type="text/css">
> table.arraydisp td {font-family:monospace; border:solid black 
> 1px;vertical-align: top;}
> table.arraydisp tr.blank td {border:none;}
> </style>
> 
> <table class="arraydisp" cellspacing="0" cellpadding="3"><tbody>
> <tr>
>   <td> <br><br><br></td>
>   <td>0<br><br><br></td>
>   <td>0 1<br><br><br></td></tr>
> <tr>
>   <td>0 1 2</td>
>   <td>0 1 2 3</td>
>   <td>0 1 2 3 4</td></tr>
> <tr class="blank">
>   <td> </td>
>   <td> </td>
>   <td> </td></tr>
> <tr>
>   <td>
>     <table class="arraydisp" cellspacing="0" 
> cellpadding="3"><tbody>      <tr>
>         
> <td>abcde<br>fghij</td></tr></tbody>    </table></td>
>   <td> <br><br><br></td>
>   <td>0<br><br><br></td></tr>
> <tr>
>   <td>0 1</td>
>   <td>0 1 2</td>
>   <td>0 1 2 3</td></tr></tbody>
> </table>
> 
> > From: Roger Hui
> > 
> > Examples to try:
> > 
> > thh i.2 2 3 4
> > thh <"0 i.2 2 3 4
> > thh 5!:2 <'assert'
> > thh 2 3 4$i.&.> i.7
> > thh x=: 2 2 3 $ (i.&.>i.6),<<2 5$'abcdefghij'
> > 
> > The last example demonstrates that vertical alignment
> > between planes can not be achieved by padding with
> > & nbsp; (because that can not account for the space used
> > by the HTML box drawing lines).  It is probably the case
> > that horizontal alignment between planes are not
> > achieved either, but the naked eye can not easily tell.
> > 
> > I will work up a version that produces vertically aligned results,
> > using width=xx in the <td> tag.  This width will depend
> > on the size of the (fixed width) font used to render the output.
> > 
> > NB. from http://www.jsoftware.com/jwiki/Essays/Boxed_Array_Display
> > sh     =: (*/@}: , {:)@(1&,)@$ ($,) ]
> > rows   =: */\...@}:@$
> > bl     =: }.@(,&0)@(+/)@(0&=)@(|/ i...@{.@(,&1))
> > mask   =: 1&,. #&, ,.&0@>:@i...@#
> > mat    =: m...@bl@rows { ' ' , sh
> > 
> > TPROLOG =: '<table border=1 cellspacing=0 cellpadding=3>',CRLF
> > TEPILOG =: '</table>',CRLF
> > BOXCHARS=: 9!:6 ''     NB. box drawing 
> characters> 
> > thh=: 3 : 0  NB. "thorn" (array formatting) producing 
> HTML output
> >  0 0 thh y
> > :
> >  if. 32 ~: 3!:0 y do.  NB. y is not boxed
> >  'h w'=. x
> >   t=. mat ": y
> >   t=. t,"1 (((*w)*w-{:$t)$' '),'<br>'
> >   t=. _4}.(,t),(4*(*h)*h-#t)$'<br>'
> >   t=. ; (a.i.t){(<' ') 32}<"0 a.
> >   ('<table><tr><td nowrap 
> valign=top><tt>'),t,'</tt></td></tr></table>'>  else.                 NB. y 
> is boxed
> >   t=. (_2&{...@$ ($,) ]) s=. ":y
> >   w=. <: 2 -~/\ I. ({.   t) e. 0 1 2{BOXCHARS
> >   h=. <: 2 -~/\ I. ({."1 t) e. 0 3 6{BOXCHARS
> >   z=. ({h;w) <@thh2"2 ,:^:(0>.2-#$y) y
> >   t=. 0 ,~ 0 -.~ bl rows y
> >   z=. ; (,z),&.> ((4*t)$&.><'<br>'),&.><CRLF
> >   if. >./x 
> do.         NB. use 
> height and width if nonzero
> >    'h w'=. x
> >    t=. $ mat s
> >    z=. '<table><tr><td 
> nowrap>',z,'</td>',CRLF>    z=. z,' <td 
> nowrap>',((6*w-{:t)$' '),'</td></tr></table>',CRLF
> >    z=. z, _4}.(4*h-{.t)$'<br>'
> >   end.
> >  end.
> > )
> > 
> > thh2=: 4 : 0  NB. rank 2 boxed argument
> >  t=. ('<td nowrap>' , '</td>' ,~ ])&.> x thh&.> y
> >  t=. <@('<tr>' , ('</tr>',CRLF) ,~ ; )"1 t
> >  TPROLOG, (;t), TEPILOG
> > )
> > 
> > 
> > 
> > ----- Original Message -----
> > From: Roger Hui <[email protected]>
> > Date: Sunday, March 28, 2010 16:16
> > Subject: Re: [Jbeta] displaying boxed array in html
> > To: Beta forum <[email protected]>
> > 
> > > This can be accomplished (I believe) by using <tt> </tt>
> > > fixed width font and using   to pad.
> > >
> > > Anyway this sort of argument can be settled
> > > by implementing a model.  This I intend to do.
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: Raul Miller <[email protected]>
> > > Date: Sunday, March 28, 2010 16:00
> > > Subject: Re: [Jbeta] displaying boxed array in html
> > > To: Beta forum <[email protected]>
> > >
> > > > On Sun, Mar 28, 2010 at 6:51 PM, Roger Hui
> > > <[email protected]> wrote:
> > > > > For arrays with rank greater than 2, you need to align
> > > > > elements at the same row and column.  That is,
> > > > > in the output x{~<i0;j;k and x{~<i1;j;k are aligned.
> > > >
> > > > The only way I know to attempt this requires the server
> > > specify the
> > > > size of each box,
> > > > which would greatly increase the complexity of this approach
> > > and
> > > > which also
> > > > might introduce new failure modes.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to