RE: Capitalizing a string?

Subject: RE: Capitalizing a string?
From: "Frank A. Christoph" <christo@xxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Dec 1998 08:12:15 +0900
>[Russell Steven Shawn O'Connor]
>> (define (char-upcase ch)
>>         (cond ((char=? #\a ch) #\A)
>>               ((char=? #\b ch) #\B)
>[...]
>
>Can someone explain why this is better than using (case)?

It's not; case is better.  cond is more general and, if anything, case will be more efficient.  In a typed language, case would also be safer.  (There are other situations, though, where you would want to use cond to perform a case-like operation.  If the scrutinee is an abstract type, for example, you might not be able to use case because case uses the language's built-in notion of equality.)

--FC


$’.+-ŠwèjwZ㍑b処m¶ŸÿÃ&ºV洳辞yÈ\¢o櫺Ë%陘,²X¬
Current Thread