Re: type string(sequence s)

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

On Wed, 10 Mar 1999, Liquid-Nitrogen Software wrote:

] type string(sequence s)
]     if find(0, (s >= 0 and s <= 255)) then
]         return 0
]     else
]         return 1
]     end if
] end type

Taking it one step further:

type string(sequence s)
    return 0 = find(0,s >= 0 and s <= 255)
end type
-- ">=", "<=", "and", "find" and "=" -- 5 calculations

But if s contains an atom it isn't spotted! So...

To infinity and beyond:

type string(sequence s)
    return 0=find(0,s=and_bits(s,255))
end type
-- "and_bits", "=", "find" and "=" -- 4 calculations = faster(untested)

However, for really long strings, the original "for" loop may be faster
because it stops at the first error rather than checking everything. EMWV.

HTH,
Carl

--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail........: cyrek- at -bigfoot.com -- Remove hyphens. Ta :)
URL...........: http://www.bigfoot.com/~cyrek/
Uncrackable...: "19.6A.23.38.52.73.45 25.31.1C 3C.53.44.39.58"

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

Search



Quick Links

User menu

Not signed in.

Misc Menu