/: should work for unicode (but not utf8).

Чт, 13 ноя 2014, jprogramming написал(а):
> /: doesn't really work for unicode, unless you convert unicode into an 
> integer mapping and then use that as x for /:
> 
> /: has the advantage of working with boxed data, or "records"/lists
> 
> With those limitations we could think of using ,:&(a.&i.)&": to build numeric 
> arrays to compare, but that runs into rank quirks with single "character" 
> left sides, so boxing seems simpler with: 
> 
>    '3'([: ,/&> ,&<&(a.&i.)&":) '3a' 
> 51  0 
> 51 97 
> 
> 
> You gain the "benefit" of being able to treat original integers as strings.
> 
> comparing then with < and > is a little harder due to handling tie breaks, 
> and you are duplicating the real work of /: in doing so?
> 
> '3'([: * [: -~/ 1 i."1~ [: (</ ,: >/ ) [: ,/&> ,&<&(a.&i.)&":) '3a'
> 
> 
> ----- Original Message -----
> From: bill lam <[email protected]>
> To: Programming forum <[email protected]>
> Cc: 
> Sent: Thursday, November 13, 2014 8:11 AM
> Subject: Re: [Jprogramming] Need analog strcmp-function verb
> 
> Sorting is an expensive operation. Could it be only once?
> 
> On Thu, Nov 13, 2014 at 8:43 PM, Henry Rich <[email protected]> wrote:
> >    strcmp =: (\: -&{. /:)@,&<
> >
> > Henry Rich
> >
> >
> > On 11/13/2014 5:35 AM, Jan-Pieter Jacobs wrote:
> >>
> >> J has total ordering (meaning anything can be sorted):
> >> http://www.jsoftware.com/jwiki/Essays/The%20TAO%20of%20J
> >>
> >> Using the verbs listed there you can define:
> >>
> >> strcmp =: _1 0 1 #~ gt , eq , lt
> >>    gt =: 1 0 -: /:@,&<
> >>    eq =: -:!.0
> >>    lt =: 1 0 -: \:@,&<
> >>
> >> ('a a a ac') strcmp&>&:;: 'ab aa a ab'
> >>
> >> 1
> >>
> >> 1
> >>
> >> 0
> >>
> >> _1
> >>
> >>
> >> 2014-11-13 11:16 GMT+01:00 Sergey Kamenev <[email protected]>:
> >>
> >>> Hello folks!
> >>>
> >>> Need strcmp verb
> >>> http://php.net/manual/function.strcmp.php
> >>>
> >>> 'a' strcmp 'ab'
> >>> 1
> >>>
> >>> 'a' strcmp 'aa'
> >>> 1
> >>>
> >>> 'a' strcmp 'a'
> >>> 0
> >>>
> >>> 'ac' strcmp 'ab'
> >>> _1
> >>>
> >>> May be you have implementation of this verb?
> >>>
> >>> Thank you!
> >>> Sergey
> >>> ----------------------------------------------------------------------
> >>> 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
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to