Re: [Scheme-reports] digit-value John Cowan (01 Jul 2012 07:15 UTC)
Re: [Scheme-reports] digit-value Peter Bex (01 Jul 2012 10:12 UTC)
Re: [Scheme-reports] digit-value John Cowan (02 Jul 2012 00:26 UTC)
Re: [Scheme-reports] digit-value Peter Bex (02 Jul 2012 07:09 UTC)
Re: [Scheme-reports] digit-value John Cowan (03 Jul 2012 03:13 UTC)

Re: [Scheme-reports] digit-value Peter Bex 02 Jul 2012 07:06 UTC

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
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports