function xor in app inventor

1,363 views
Skip to first unread message

Руслан Краснощёков

unread,
Feb 18, 2015, 9:50:36 AM2/18/15
to mitappinv...@googlegroups.com
How can i xor two numbers in app inventor?
I did in this way : x xor y = x•not y + not x•y.
But i cant add numbers to logic block.

Abraham Getzler

unread,
Feb 18, 2015, 11:14:17 AM2/18/15
to mitappinv...@googlegroups.com
Apparently, AI2 enforces type constraints for logical
blocks and math blocks.

You can't code 1 AND 1
but you can code True AND True.

This doesn't preclude you from writing conversion routines
to convert your numbers into text strings of 1's and 0's,
and writing your own string versions of AND, OR, NOT, XOR, etc.

Or you could convert numbers to lists of booleans, 
then knit two lists together into a third list bool by bool using the logic blocks.

What fun!

ABG


Руслан Краснощёков

unread,
Feb 19, 2015, 3:20:16 AM2/19/15
to mitappinv...@googlegroups.com
please tell me, how can I do xor two Math numbers?

Abraham Getzler

unread,
Feb 19, 2015, 10:22:14 PM2/19/15
to mitappinv...@googlegroups.com
See attached.
ABG

tests.jpg
xor.jpg
xor10.jpg

Scott Ferguson

unread,
Feb 20, 2015, 5:52:38 PM2/20/15
to mitappinv...@googlegroups.com
Nicely done, and recursive!
---
sf

Руслан Краснощёков

unread,
Feb 21, 2015, 1:35:11 AM2/21/15
to mitappinv...@googlegroups.com
Large thanks Abraham Getzler! You helped me Very !!!!
Reply all
Reply to author
Forward
0 new messages