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 <[email protected]> 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 <[email protected]> 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