See my msg. As well: > What problem would occur if characters could be compared with each other?
< has dyadic ranks 0 0, so 'foo' < 'bar' would have answer 0 0 1 and 'foo' <'barf' would be a length error. Probably not what one'd want. On Sun, Oct 30, 2011 at 7:35 PM, Alan Stebbens <[email protected]> wrote: > I get sad when I see both expert and new J programmers working hard to do > simple string comparisons. J makes working with strings harder than it > should to be. > > I still have no idea why these comparison expressions are domain errors: > > 'abc' > 'def' > |domain error > | 'abc' >'def' > > 'def' < 'abc' > |domain error > | 'def' <'abc' > > What problem would occur if characters could be compared with each other? > > Strangely, compare equal works, but not how you think: > > 'abc' = 'def' > 0 0 0 > > So, of course, strings are just arrays of characters. > > So, if strings are arrays of characters, and equality knows how to compare > characters, why don't the other comparison operators know how to compare > characters? > > J can manage most (any?) programming tasks but common things like comparing > strings ought to be easy. > > Yes, I know that there are string utilities in stdlib.j, but the utilities > are not well evangelized. > > String processing is as important a function to real-world computing as is > numeric processing, and J is certainly capable of it. But, it has been > treated as the "red-headed step-child" and left out of most of the > documentation. > > If you browse the help documentation tree, the word "string" occurs once in > the "Primer", three times in JforC, but does not occur in any of "Usr", "LJ", > "Phr", "Dic", "Rel", or "Voc" sections. There are no mentions of what stdlib. > > Why aren't there standard phrases for string operations in Phrases? Most > modern languages provide string functions, either natively, or as "core" > functions. > > The "Help" index really out to have a "Lib" section, with a list of the > various libraries, including "stdlib" and "regex", their functions, > arguments, and descriptions. > > > Alan > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
