() "Bill Schottstaedt" <b...@ccrma.stanford.edu>
() Fri, 19 Dec 2008 06:55:21 -0800

   Why do both Guile and Gauche give this result in string-ci<?
   (and the other string-ci functions similarly):

   The odd chars are ASCII 91 to 96:

ASCII 91-96 lie between the two ranges A-Z and a-z.
One procedure smashes case up and the other down.
Smashing happens unconditionally.

(define (my-char-ci<? p q)
  (< (down p)) (down q))

Another more complicated (but arguably more correct) approach
would be to determine if one/both of the args are not smashable,
and entirely avoid smashing in that case.  Something like:

(define (smashable? c)
  (or (<= #\a c #\z) (<= #\A c #\Z)))

(define (my-char-ci<? p q)
  (if (and (smashable? p) (smashable? q))
      (< (down p) (down q))
      (< p q)))

Pseudoscheme (numeric operators don't actually take chars),
but you get the idea.

thi



Reply via email to