From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: bug-guile@gnu.org
Subject: Re: string-ci* oddity
Date: Fri, 02 Jan 2009 03:36:09 +0100 [thread overview]
Message-ID: <873ag2igdi.fsf@ambire.localdomain> (raw)
In-Reply-To: 20081219145350.M61823@ccrma.Stanford.EDU
() "Bill Schottstaedt" <bil@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
next prev parent reply other threads:[~2009-01-02 2:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-19 14:55 string-ci* oddity Bill Schottstaedt
2009-01-02 2:36 ` Thien-Thi Nguyen [this message]
2009-02-02 0:00 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873ag2igdi.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=bug-guile@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).