For single characters compared to strings you could use the uucp (defined in
the standard library)
a. i. 'éabc'
195 169 97 98 99
a. i. uucp 'éabc'
233 97 98 99
uucp
u:@(7&u:)
'b' >&(a. i. uucp) 'éabc'
0 1 0 0
'b' <&(a. i. uucp) 'éabc'
1 0 0 1
'b' <:&(a. i. uucp) 'éabc'
1 0 1 1
Cheers, bob
> On Dec 10, 2022, at 12:18, Raul Miller <[email protected]> wrote:
>
> Comparing strings is different from comparing characters.
>
> One approach would be to compare boxed strings -- this would require
> using the (-: /:) mechanism. Or, perhaps (-: /:)"0 depending on the
> desired result.
>
> Another approach would compare character lists. This would require
> they be the same length. Here, you could use the <&(3&u:) mechanism
> but it would fail on unequal length strings (just as < would fail on
> unequal length number lists).
>
> Anyways, ... unicode gets into some "interesting territory" when
> talking about ordering of "characters":
>
> B0=: {.B1=: 7 u: B2=: 'β'
> B0
> β
> B1
> β
> B2
> β
> B0 >&(3&u:) B1
> 0
> B0 >&(3&u:) B2
> 1 1
>
> It's really simple.
>
> Except, when it's not.
>
> --
> Raul
>
> On Sat, Dec 10, 2022 at 2:49 PM Devon McCormick <[email protected]> wrote:
>>
>> Raul's expression "<&(3&u:)" made me think of the endless complications for
>> character comparison once you include multi-byte representations as in
>> Unicode.
>> So this initial expression works fine but extending it beyond elements of a.
>> leads to ambiguity.
>> 'A' <&(3&u:) 'a'
>> 1
>> a. i. 'Aa' NB. confirming the inequality
>> 65 97
>> NB. (load "define-abbrev-table.el") NB. This allows me to enter special
>> characters in emacs
>> 'α' <&(3&u:) 'a'
>> 0 0
>> 'α' <&(3&u:) 'β' NB. So should we say alpha is only partially
>> less than beta?
>> 0 1
>> (<a.) i. &> 'α';'β'
>> 206 177
>> 206 178
>>
>>
>>
>> On Sat, Dec 10, 2022 at 7:28 AM 'Mike Day' via Chat <[email protected]>
>> wrote:
>>
>>> Yes, my suggestion was an example of using /:~ to exploit J's inbuilt
>>> ordering for a
>>> simple, quick answer; but maybe
>>> /:~ 'aA1.;'
>>> (eg) isn't the order relation you require, so I agree with Raul.
>>>
>>> Mike
>>>
>>> Sent from my iPad
>>>
>>>> On 9 Dec 2022, at 19:22, Jimmy Gauvin <[email protected]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> the domain of < and others could be extended to include characters.
>>>>
>>>> Sorting with /: and \: implies there is an "order" relation between
>>>> characters.
>>>>
>>>>
>>>> J
>>>>
>>>>> On Fri, Dec 9, 2022 at 6:21 AM Donna Ydreos <[email protected]> wrote:
>>>>>
>>>>> The domain of < is numeric. You can create a function for letters with
>>>>> reference to alphabetic order or some given order including say all ASCI
>>>>> characters.
>>>>>
>>>>>>> On Dec 9, 2022, at 3:47 AM, Jimmy Gauvin <[email protected]>
>>> wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> testing character data for equality works fine but testing for relative
>>>>>> order does not.
>>>>>>
>>>>>> 'a'<'v'
>>>>>>
>>>>>> |domain error
>>>>>>
>>>>>> | 'a' <'v'
>>>>>>
>>>>>> 'a'='v'
>>>>>>
>>>>>> 0
>>>>>>
>>>>>> Is this explained somewhere ?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Jimmy
>>>>>> ----------------------------------------------------------------------
>>>>>> 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
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>
>>
>> --
>>
>> Devon McCormick, CFA
>>
>> Quantitative Consultant
>> ----------------------------------------------------------------------
>> 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