bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string-ci* oddity


From: Thien-Thi Nguyen
Subject: Re: string-ci* oddity
Date: Fri, 02 Jan 2009 03:36:09 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

() "Bill Schottstaedt" <address@hidden>
() 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

[Prev in Thread] Current Thread [Next in Thread]