1. Re: Win32Lib --Duh
- Posted by Mike <michael at IGRIN.CO.NZ>
Jan 22, 1999
-
Last edited Jan 23, 1999
>Greg Harris wrote:
>
>> Hi Bret!
>>
>> I just noticed the code I sent you was a little sloppy for my standards..
it
>> worked but wasn't well optimized..
>> Why use for loops when you can take advantage of Euphoria's sequence
>> operations and bool ops.
>>
>> include wildcard.e
>>
>> --Range function originally by Hawke'
>> --Modified by Greg Harris
>> function range(object data, integer low, integer high)
>> return data * (data>=low) * (data<=high)
>> end function
>>
--- SNIP SNIP SNIP-----------------------------------
If you're serious about optimizing this kind of code (for speed - what else)
then try these ....
I haven't bothered with types or multi-level sequences, sorry Ralf.
function numeric(sequence s) -- test whether a string has all valid numeric
characters
integer c
for i=1 to length(s) do
c=s[i]
if c<'0' then return 0
elsif c>'9' then return 0
end if
end for
return 1
end function
function alpha(sequence s) -- test whether a string has all valid alphabetic
characters
integer c
for i=1 to length(s) do
c=s[i]
if c<='Z' then
if c<'A' then return 0 end if
elsif c>='a' then
if c>'z' then return 0 end if
end if
end for
return 1
end function