From: Tiarnán Ó Corráin
Subject: How to test a string contains only numbers?
Date:
Message-ID: <m2mzqzo239.fsf@Cascade.local>
Hello--
I'm trying to find out whether a string contains only numbers. I
expected
(every #'numberp "1234")
to succeed, since
(every #'numberp #(1 2 3 4))
does, but no joy.
I suspect it's because "1234" is really #(#\1 #\2 #\3 #\4).
--
Tiarn�n
From: Lars Brinkhoff
Subject: Re: How to test a string contains only numbers?
Date:
Message-ID: <85y8ajpfv4.fsf@junk.nocrew.org>
········@yahoo.com (Tiarn�n � Corr�in) writes:
> I'm trying to find out whether a string contains only numbers. I
> expected
> (every #'numberp "1234")
> to succeed, since
> (every #'numberp #(1 2 3 4))
> does, but no joy.
(every #'digit-char-p "1234")
From: Tiarnán Ó Corráin
Subject: Re: How to test a string contains only numbers?
Date:
Message-ID: <m2fywrnwrl.fsf@Cascade.local>
Lars Brinkhoff <·········@nocrew.org> writes:
> ········@yahoo.com (Tiarn�n � Corr�in) writes:
>> I'm trying to find out whether a string contains only numbers. I
>> expected
>> (every #'numberp "1234")
>> to succeed, since
>> (every #'numberp #(1 2 3 4))
>> does, but no joy.
>
> (every #'digit-char-p "1234")
Thank you.
--
Tiarn�n
········@yahoo.com (Tiarn�n � Corr�in) writes:
> Hello--
>
> I'm trying to find out whether a string contains only numbers. I
> expected
> (every #'numberp "1234")
> to succeed, since
> (every #'numberp #(1 2 3 4))
> does, but no joy.
>
> I suspect it's because "1234" is really #(#\1 #\2 #\3 #\4).
The problem is that you are confounding two different notions:
number and digit.
Digits are some designated characters, used to write some
representations of numbers.
Numbers are mathematical abstractions used to "compute".
Try: (every (function digit-char-p) "1234")
--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush