On Sun, Jul 01, 2012 at 08:26:24PM -0400, John Cowan wrote: > Peter Bex scripsit: > > > Alternatively, change it to accept just the ASCII number characters, > > and possibly with Marc's suggestion of accepting digits in any base > > (and perhaps an optional second argument to specify which base we're > > working in). That would really be useful, since that could be used > > to implement very common char->number conversion and could even be > > used internally in string->number (at least conceptually). > > It's quite common (though technically not portable) to determine that a > character is a digit using `char-numeric?` and then determine its value > using `(- (char->integer x) (char->integer #\0))` or the equivalent.
Code that does this will very often also contain code that does something similar for hex-digits. Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth _______________________________________________ Scheme-reports mailing list [email protected] http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
