Re: questions, questions; always questions :)

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

On Sun, 6 Sep 1998, Hawke wrote:

[Snippy. I like this thread, it's just that replies are getting very
large!]

> here's one that is TRUE:
>   -- x={200,432,56,618}    MaxX=640
>   -- y={112,252,35,460}    MaxY=480
>   -- if (x<MaxX) and (y<MaxY) and
>   --    (x>=0)   and (y>=0)   then
>   --    plot(x,y,GREEN)
>   -- end if
>   -- now look at the intermediate/final results:
>   -- if {1,1,1,1} and {1,1,1,1} and
>         {1,1,1,1} and {1,1,1,1} then
>         plot(x,y,GREEN) end if
>   -- if TRUE and TRUE and TRUE and TRUE then
>   -- if TRUE then   ---okay we do the if..then statement.
> no, i am not looking for 'case' here
> i am looking for =consistency=.

Easy!

Add some code and change the if statement like so:

constant True = 1, False = 0
-- I assume these are declare somewhere before.
-- They just make the code more intuitive.
-- Remember: True = not False and False = not True

function alltrue(sequence of_conditions)
    return not find(False, of_conditions)
end function

if alltrue(x<MaxX) and alltrue(y<MaxX) and
   alltrue(x>=0)   and alltrue(y>=0)   then

   -- etc.

end if

And the program's logic is still intact!

To be honest though, does the plot() statement really work like that?

The function allfalse() and how to use "*not* allwhatever()" are left as
exercises to the Euphoria community :)

Happy Coding,
Carl

--
Carl R White
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
Url......: http://www.bigfoot.com/~cyrek/
In my last few days on the net, I have room for a witty quote. Irony. :S

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

Search



Quick Links

User menu

Not signed in.

Misc Menu