1. a question about syntax
Hi !
Do you know how to do this little thing with eu :
ex :
(with C)
bool flag, flag2;
flag = RandomBoolValue();
flag2 = !flag;
is there a quicker way than :
integer flag, flag2
flag=RandomTrueFalse()
if flag=true then flag2=false
else flag2=true
end if
?
I'll use this very often in my code, and I don't want to put 3 lines each
times I need an opposite of a true/false value.
thank you.
Gwen
2. Re: a question about syntax
> Do you know how to do this little thing with eu :
> ex :
> (with C)
> bool flag, flag2;
> flag = RandomBoolValue();
> flag2 = !flag;
>
> is there a quicker way than :
>
> integer flag, flag2
> flag=RandomTrueFalse()
>
> if flag=true then flag2=false
> else flag2=true
> end if
>
> ?
Try
----------
integer a,b
a=2-rand(2)
b = not a -- your task, "not" in Eu instead of "!" in C
? a
? b
----------
regards
Igor Kachan
3. Re: a question about syntax
Gwen writes;
<snip>
> Do you know how to do this little thing with eu :
> ex :
> (with C)
> bool flag, flag2;
> flag = RandomBoolValue();
> flag2 = !flag;
>
> is there a quicker way than :
>
> integer flag, flag2
> flag=RandomTrueFalse()
>
> if flag=true then flag2=false
> else flag2=true
> end if
integer flag, flag2
flag=RandomTrueFalse()
flag2=not flag
The Euphoria keyword "not" is the exact equivalent of C's "!"
--Mike Nelson