1. Re: Short Circuiting

On Thu, 25 Jun 1998 17:33:18 +0700 Andy Kurnia <akur at DELOS.COM> writes:
>>Date:    Wed, 24 Jun 1998 17:31:07 -0400
>>From:    Robert B Pilkington <bpilkington at JUNO.COM>
>>Subject: Re: Short Circuiting
>>
>>And here's a real solution. :)
>>
>>if match("EOF", s) = 1 then
>
>    Ah!!! you found it smile
>
>    How hard would it be to check if "EOF" is the LAST 3 elements
>    in the sequence? Well, what if s = "TestingforEOFhere:EOF"??

if length(s) < 3 then  -- Make s at least length() 3
    s = repeat(255, 3)
end if
if compare(s[length(s)-3..length(s), "EOF")=0 then
    -- Alpha
else
    -- Gamma
end if
if s[1] = 255 then
    s = s[3..length(s)]
end if

See? :) (Or just use David's safe slicing routine. :)

>    What if s is an atom???

David's first example (if length(s) >= 3) would fail if s isn't a
sequence, and s is assumed a sequence here.

If you must, though (this assumes s is an object):

if not sequence(s) then
    s = {s}
end if

Problem solved. s is now a sequence. :)


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu