[Jprogramming] Boxing Issues
'Rob Hodgkinson' via Programming
programming at jsoftware.com
Wed Jul 8 01:39:23 UTC 2020
Sorry to double up, had not seen Brian’s reply when I sent…/Rob
> On 8 Jul 2020, at 11:37 am, 'Rob Hodgkinson' via Programming <programming at jsoftware.com> wrote:
>
> Skip, this may help you with your preferred display.
>
> I believe it used to be possible to configure box display (whether to have top/bottom of boxes etc), but I think that was deprecated instead to allow box drawing characters as an 11 item list, which is available through the foreign conjunction 9!:6 (to view) and 9!:7 (to set), for example:
>
> 9!:6’’ NB. This is the 11 element vector of box drawing chars
> ┌┬┐├┼┤└┴┘│─
>
> 9!:7 '|' 9}11${.a. NB. I now set this to ‘………|.’ (Where the ‘.’ Is a null which is {.a.)
>
> 9!:6''
> | NB. This is an 11 item vector, but all box chars except the separator are nulls
> $9!:6''
> 11
>
> ]m=.'abc';'rtyuio';'b';'asdf';'wdrtybji';'ee';'nuko';'n'
>
> |abc|rtyuio|b|asdf|wdrtybji|ee|nuko|n|
>
> NB. The output above is 3 lines (first line is a list of nulls, second line is delimited boxes, 3rd line is a list of nulls)
>
> NB. So only the separators appear (it displays ‘aligned’ in the example below in my session and font, but unlikely to appear this way in email).
>
> 2 4$m
>
> |abc |rtyuio|b |asdf|
>
> |wdrtybji|ee |nuko|n |
>
>
> Maybe it’s close enough for you to use.
>
> Rob
>
>> On 8 Jul 2020, at 9:59 am, Skip Cave <skip at caveconsulting.com> wrote:
>>
>> Thanks Hauke for your reply. That helped me see how to proceed.
>>
>> I mentioned that it would still be nice to have a simple way to remove the
>> horizontal and corner box characters for times when presenting J in venues
>> where fixed-width or unicode fonts are not available.
>>
>>
>> Here's what i mean:
>>
>> m=.'abc';'rtyuio';'b';'asdf';'wdrtybji';'ee';'nuko';'n'
>>
>> Not this:
>>
>> m
>>
>> ┌───┬──────┬─┬────┬────────┬──┬────┬─┐
>>
>> │abc│rtyuio│b│asdf│wdrtybji│ee│nuko│n│
>>
>> └───┴──────┴─┴────┴────────┴──┴────┴─┘
>>
>>
>> But this:
>>
>> m
>>
>> │abc│rtyuio│b│asdf│wdrtybji│ee│nuko│n│
>>
>>
>>
>> Not this:
>>
>> 2 4$m
>>
>> ┌────────┬──────┬────┬────┐
>>
>> │abc │rtyuio│b │asdf│
>>
>> ├────────┼──────┼────┼────┤
>>
>> │wdrtybji│ee │nuko│n │
>>
>> └────────┴──────┴────┴────┘
>>
>>
>> But this:
>>
>> 2 4$m
>>
>> │abc│rtyuio│b│asdf│
>>
>> │wdrtybji│ee│nuko│n│
>>
>>
>> As a format option.
>>
>>
>> Skip Cave
>> Cave Consulting LLC
>>
>>
>> On Tue, Jul 7, 2020 at 12:44 PM Hauke Rehr <hauke.rehr at uni-jena.de> wrote:
>>
>>> Hi Skip,
>>>
>>> this is how I would try to achieve what you’re after
>>>
>>> ] suits =: u: 9824 9827 9829 9830
>>> ♠♣♥♦
>>> ;/ values =: (3 2 $ ' J Q K') , ": >: i. 10 1
>>> ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
>>> │ J│ Q│ K│ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│ 9│10│
>>> └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘
>>> deck =: ,/ values ,"1/ ":"0 suits
>>> _4 <\ deck
>>> ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
>>> │ J♠│ Q♠│ K♠│ 1♠│ 2♠│ 3♠│ 4♠│ 5♠│ 6♠│ 7♠│ 8♠│ 9♠│10♠│
>>> │ J♣│ Q♣│ K♣│ 1♣│ 2♣│ 3♣│ 4♣│ 5♣│ 6♣│ 7♣│ 8♣│ 9♣│10♣│
>>> │ J♥│ Q♥│ K♥│ 1♥│ 2♥│ 3♥│ 4♥│ 5♥│ 6♥│ 7♥│ 8♥│ 9♥│10♥│
>>> │ J♦│ Q♦│ K♦│ 1♦│ 2♦│ 3♦│ 4♦│ 5♦│ 6♦│ 7♦│ 8♦│ 9♦│10♦│
>>> └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
>>>
>>> deck is pretty much your all in
>>> 4 13$(52?52){all
>>> As long as you don’t do any boxing, you won’t
>>> need to get rid of boxing characters.
>>> You can always insert | characters manually, though.
>>> If you feel like they make the dealt hands more readable.
>>>
>>> Am 07.07.20 um 18:45 schrieb Skip Cave:
>>>> The four suit symbols I was using were from a. 3 4 5 6{a.
>>>>
>>>> These symbols are not the same width as the character symbols in a. so
>>> they
>>>> mess up the boxing characters.
>>>>
>>>> ;/3 4 5 6{a.
>>>>
>>>> (My email fonts don't have the a. symbols)
>>>>
>>>> ┌─┬─┬─┬─┐
>>>>
>>>> │ │ │ │ │
>>>>
>>>> └─┴─┴─┴─┘
>>>>
>>>> I discovered that the unicode suit symbols u: 9824 9827 9829 9830
>>>>
>>>> are smaller, and seem to have the standard width:
>>>>
>>>> ;/u:9824 9827 9829 9830
>>>>
>>>> ┌─┬─┬─┬─┐
>>>>
>>>> │♠│♣│♥│♦│
>>>>
>>>> └─┴─┴─┴─┘
>>>>
>>>> So that solves the width problem when boxing.
>>>>
>>>>
>>>> The other issue I had with seemingly random spaces in the cards in a
>>> random
>>>> deal was caused by my four 10 cards (10 of spades, hearts. etc) having
>>>> three characters instead of two. J cleverly distributes spaces across
>>> each
>>>> boxes' content to make the boxes align. However, the seemingly random
>>>> distribution of spaces confused my diagnosis.
>>>>
>>>> J distributes spaces across all the cells to make the boxes align for
>>>> variable width contents. This exacerbates the issue with the non-standard
>>>> widths of the a. font. However, the fixed-width unicode symbols
>>> eliminates
>>>> the issue, though it might be better if the spaces were inserted before
>>> or
>>>> after the characters, rather than placed in the middle.
>>>>
>>>>
>>>> 4 13$(52?52){all
>>>>
>>>> ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
>>>>
>>>> │10♠│9 ♣│K ♥│3 ♣│J ♦│4 ♠│4 ♦│2 ♠│6 ♥│3 ♠│K ♦│Q ♥│J ♣│
>>>>
>>>> ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
>>>>
>>>> │5 ♥│5 ♠│9 ♥│Q ♠│7 ♦│5 ♣│3 ♥│10♦│8 ♦│J ♥│4 ♣│9 ♦│6 ♣│
>>>>
>>>> ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
>>>>
>>>> │8 ♣│J ♠│A ♣│7 ♣│Q ♦│6 ♦│10♣│K ♣│A ♥│2 ♥│A ♠│4 ♥│9 ♠│
>>>>
>>>> ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
>>>>
>>>> │7 ♠│3 ♦│5 ♦│Q ♣│8 ♥│2 ♦│10♥│A ♦│K ♠│7 ♥│2 ♣│8 ♠│6 ♠│
>>>>
>>>> └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
>>>>
>>>> It would probably be better for me to use the character 'T' instead of
>>> 10,
>>>> so all the cards would have two characters.
>>>>
>>>>
>>>> Finally, it would still be nice to have a simple way to remove the
>>>> horizontal and corner box characters for times when presenting J in
>>> venues
>>>> where fixed-width or unicode fonts are not available.
>>>>
>>>>
>>>> Skip Cave
>>>>
>>>> On Tue, Jul 7, 2020 at 10:20 AM Raul Miller <rauldmiller at gmail.com>
>>> wrote:
>>>>
>>>>> If the fixed width font has variable width characters, that's not a
>>>>> bug in J, that's a problem with the font.
>>>>>
>>>>> One approach would be to rebuild the font's characters, enforcing a
>>>>> fixed width format. Doing this requires access to either suitable
>>>>> tools, or sufficient documentation on the font's data structures so
>>>>> that you can build your own tools.
>>>>>
>>>>> --
>>>>> Raul
>>>>>
>>>>> On Tue, Jul 7, 2020 at 11:10 AM Skip Cave <skip at caveconsulting.com>
>>> wrote:
>>>>>>
>>>>>> When working in JQT with some of the non-standard-width characters in
>>> a.,
>>>>>> the boxing formatting is incorrect.
>>>>>> Here's a link to a screenshot (.png) of my code in JQT attempting to
>>>>> create
>>>>>> all the 13 playing cards in 4 suits. https://bit.ly/2BD6LEQ
>>>>>>
>>>>>>
>>>>>> As you can see, the horizontal boxing characters are incorrect, and
>>> don't
>>>>>> adjust for the wider characters, even though I'm using a fixed-width
>>>>> font.
>>>>>>
>>>>>> In the second part of the example, I randomly deal 4 hands from the
>>> deck
>>>>>> labeled 'all'.
>>>>>>
>>>>>> At this point, we have 4 hands of 13 cards, but there are random spaces
>>>>>> scattered in the boxed cards.
>>>>>>
>>>>>> Something went wrong, adding spaces after the random deal.
>>>>>>
>>>>>> In the third part, I remove all the horizontal boxing, making the
>>> display
>>>>>> look much neater, but the extra spaces are even more visible.
>>>>>>
>>>>>>
>>>>>> Two issues:
>>>>>>
>>>>>> 1. Something is inserting random spaces when randomly selecting boxed
>>>>> items.
>>>>>>
>>>>>> 2. It would be nice to have the boxing auto-adjust for variable width
>>>>>> characters. If that isn't possible, it would be useful to have a boxing
>>>>>> format option to remove horizontal boxing & corner characters for
>>>>>> environments that don't have fixed-with fonts, that use
>>>>> non-standard-width
>>>>>> characters, or that force double-spaced lines (Quora). After posting J
>>>>>> problems and solutions in various venues, it turns out that the
>>> vertical
>>>>>> bar (│) without horizontal bars or corners, is quite enough to clearly
>>>>>> delineate separate items in most cases.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Skip Cave
>>>>>> Cave Consulting LLC
>>>>>> ----------------------------------------------------------------------
>>>>>> 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
>>>>
>>>
>>> --
>>> ----------------------
>>> mail written using NEO
>>> neo-layout.org
>>>
>>> ----------------------------------------------------------------------
>>> 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
More information about the Programming
mailing list