1. No xor!!!
Why is there no xor operator, imp, or eqv? How do you xor stuff if you
don't have it???
_________________
"When it comes to programming languages, Eu™ by RDS is a cut above" -
Matt1278 and SoftPrez
Webbers: <A HREF="mailto:softprez at juno.com">softprez at juno.com</A>,
president of SoftCo.® Uh, no slogan at the moment™
Seeya next week!
2. Re: No xor!!!
>Why is there no xor operator, imp, or eqv? How do you xor stuff if you
>don't have it???
Eh, well, Matt, never played attention at your Science Class ?
There you go:
a xor b = ( a and ( not b ) ) or ( not (a) and b )
Ralf Nieuwenhuijsen
>>>>>>>>>>>>>>>
nieuwen at xs4all.nl
ralf_n at email.com
tp2 at email.com
UIN: 9389920
3. Re: No xor!!!
On Mon, 26 Oct 1998, Matt Z Nunyabidness wrote:
> Why is there no xor operator, imp, or eqv? How do you xor stuff if you
> don't have it???
I assume you want to do things like:
if a = 3 xor b = 4 then...
Easy. Just do this instead (note the brackets. They *have* to be there to
use this trick):
if (a = 3) != (b = 3) then...
^^^^-xor is bitwise inequality
For eqv:
if (a = 3) = (b = 4) then...
^^^-eqv is bitwise EQuiValence
For imp:
if (a = 3) or not (b = 4) then...
^^^^^^^^-imp is logical IMPlication (not obvious here)
If you're not wanting logical expressions, but bitwise operations,
Euphorias 1.5+ have the functions
and_bits(), or_bits() and xor_bits().
There may be some old libraries out there that emulate these using
int_to_bits(), bits_to_int(), and "not", "and" and "or".
HTH,
Carl
--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
URL......: http://www.bigfoot.com/~cyrek/
Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa
4. Re: No xor!!!
Matt wrote and Ralf responded:
>>Why is there no xor operator, imp, or eqv? How do you xor stuff if
>>you don't have it???
>Eh, well, Matt, never played attention at your Science Class ? There
>you go:
>a xor b = ( a and ( not b ) ) or ( not (a) and b )
I hate it, but I must agree with Matt.
We already have some pretty useless routines, just for the sake of
completeness (object() function springs to mind). It would make more
sense to have a complete set of logical operators. Especially since
replacement routines are typically 5 to 20 times slower than their
implemented cousins. jiri
5. Re: No xor!!!
Jiri Babor wrote ...
>We already have some pretty useless routines, just for the sake of
>completeness (object() function springs to mind). It would make more
>sense to have a complete set of logical operators.
I agree. Although I can understand the 'just write the required
function' approach to extend Euphoria's abilities, it would be much
nicer to have in-built functions to achieve the common things in life.
These shouldn't really add too much extra to the interpreter [ should
they ? ].
I particularly dislike the ramainder() function and would love to see an
in-built 'mod' function ala
a = 9 mod 4 -- instead of a = remainder(9,4)
Comparative operators ( >=, != etc ) should really be extended, in the
same spirit, to cover all types without having to use the compare()
function, ala
a = "Alfred"
b = "George"
if ( a < b ) ....
Now I know there's going to be an argument that this will start making
Euphoria look more and more like Basic, but, it would make it much
easier for newcomers ( like me ) to get into the language much quicker.
And afterall, commercial success must be one of Euphoria's goals.
One of the reasons I was asking about a Wish-List in an earlier posting
is that Euphoria is one of the few languages where
the-person-in-the-street actually has some input on the way the language
develops. A refreshing change.