[plt-scheme] boolean operators on integers

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Sat Jul 12 10:04:14 EDT 2008

wooks wrote:
> Seems like and is just returning the value of the last argument.
> The integers 0 and 1 are supposed (for my purposes ) to be boolean
> flags true and false so this is not the behaviour that I want.
In Scheme all values except #f is considered to be true values. Thus 
both 0 and 1
are interpreted by and as being true. Hence (and 0 1) gives true.

What you need are the bitwise operations, which operate on the bit level.

 > (bitwise-and 1 1)

 > (bitwise-and 1 0)

Jens Axel Søgaard

Posted on the users mailing list.