Re: type string
At 11:50 AM 12-03-1999 , you wrote:
>Here's Jeff's winning (modified) string type:
>
>global type string6(object s)
> object c
> if not sequence(s) then
> return 0
> end if
> for i = 1 to length(s) do
> c = s[i]
> if integer(c) then
> if (c < 0) or (c > 255) then
> return 0
> end if
> else
> return 0
> end if
> end for
> return 1
>end type
Very fasy!
You should change the not sequence() and integer() test for atom(), if it's
not a sequence then what is it? and we already know that fp numbers are
valid characters in Euphoria.
You also need to change c<0 to c<1, zero ain't valid on strings.
global type string(object s)
object c
if atom(s) then
return 0
end if
for i = 1 to length(s) do
c = s[i]
if atom(c) then
if (c<1) or (c>255) then
return 0
end if
else
return 0
end if
end for
return 1
end type
Regards,
Daniel Berstein
[daber at pair.com]
|
Not Categorized, Please Help
|
|