jsoftware / jsource

J engine source mirror
Other
645 stars 91 forks source link

One-character strings returned by 'convert/pjson' can't be compared #138

Closed hckiang closed 2 years ago

hckiang commented 2 years ago

Not sure if this is a bug?

   load 'convert/pjson'
   x=.dec_pjson_ enc_pjson_ ('TXT';'A';'CNAME';'MX') 
   x                              NB. Let's see what's in here...
┌───┬─┬─────┬──┐
│TXT│A│CNAME│MX│
└───┴─┴─────┴──┘
   x = <'TXT'                     NB. OK...
1 0 0 0
   x = <'MX'                      NB. Also good...
0 0 0 1
   x = <'A'                       NB. Why??
0 0 0 0
   y=.('TXT';'A';'CNAME';'MX')    NB. Let's make the same thing manually
   y = <'A'                       NB. So if I make the list of string manually it works
0 1 0 0
   y = x                          NB. But the 'A' in x is different from the 'A' in y
1 0 1 1
   (>1{y) = (>1{x)                NB. But everything returns to normal after unboxing x?
1
   (<>1{x) = (<>1{y)              NB. It will fail if you box it back up again
0

Some OS information: OS: Linux J version: 904 beta-a System Locale:

LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_COLLATE=C
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_PAPER="sv_SE.UTF-8"
LC_NAME="sv_SE.UTF-8"
LC_ADDRESS="sv_SE.UTF-8"
LC_TELEPHONE="sv_SE.UTF-8"
LC_MEASUREMENT="sv_SE.UTF-8"
LC_IDENTIFICATION="sv_SE.UTF-8"
LC_ALL=
bilam commented 2 years ago

I think this is not a bug. And your question is unrelated to jsource. Please post to j forum or stackoverflow instead.

hckiang commented 2 years ago

Thanks!

HenryHRich commented 2 years ago

This is probably a rank difference, which is hard to spot and tricks newcomers.

<'A' is not equal to <,'A' but they look the same.

Henry Rich

On Thu, Jun 16, 2022, 4:50 PM Hao Chi Kiang @.***> wrote:

Not sure if this is a bug?

load 'convert/pjson'

x=.decpjson encpjson ('TXT';'A';'CNAME';'MX')

x NB. Let's see what's in here...

┌───┬─┬─────┬──┐

│TXT│A│CNAME│MX│

└───┴─┴─────┴──┘

x = <'TXT' NB. OK...

1 0 0 0

x = <'MX' NB. Also good...

0 0 0 1

x = <'A' NB. Why??

0 0 0 0

y=.('TXT';'A';'CNAME';'MX') NB. Let's make the same thing manually

y = <'A' NB. So if I make the list of string manually it works

0 1 0 0

y = x NB. But the 'A' in x is different from the 'A' in y

1 0 1 1

(>1{y) = (>1{x) NB. But everything returns to normal after unboxing x?

1

— Reply to this email directly, view it on GitHub https://github.com/jsoftware/jsource/issues/138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKVAJ3ZCKDD7WZ5SWKZTEDVPM5KDANCNFSM5Y7CHO2Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

hckiang commented 2 years ago

Thanks!