1. Re: Win32Lib --Duh

>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.
blink

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

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu