Re: type string

new topic     » topic index » view thread      » older message » newer message

Hi,
  I couldn't resist jumping in on an optimization race:)
This one runs a bit faster in my tests, especially for
longer sequences.

-----------------------------------------------
global type string13(object x)

   if atom(x) then
      return 0
   end if

   -- ensure all elements are in the range 0 to 255
   if compare(x, and_bits(255, x)) then
      return 0
   end if

   -- ensure there's no sub-sequences
   for i = 1 to length(x) do
      if not integer(x[i]) then
         return 0
      end if
   end for
   return 1
end type
-----------------------------------------------

Have fun,
Christopher D. Hickman

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu