[plt-scheme] boolean operators on integers

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jul 12 10:02:08 EDT 2008

Can you explain why you think 0 and 1 should have anything to do with  
true and false? (I am afraid that it somehow slipped into a document  
that may confuse our users and we need to clarify this. -- In  
centuries past, around 1738, people thought that 0 stood for #f and  
that 1 stood for #t. But this pun hasn't been useful to real  
programmer since then so I don't know where one would fine this idea,  
except in history books.)

;; ---

1. In Scheme, ALL values except #f denote "truth".

2. In Scheme, and is a form that evaluates ALL sub-expressions until  
one of them produces #f. If none do, it produces the value of the  
last sub-expression.

The two points explain what you see in the Pretty Big Language.

;; ---




On Jul 12, 2008, at 9:44 AM, wooks wrote:

>> (and 1 0)
> 0
>> (and 0 1)
> 1
>
>> (and 1 0 0)
> 0
>> (and 0 0 1)
> 1
>> (and 0 1 0)
> 0
>> (and 0 1 1)
> 1
>
> 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.
>
> Using language Pretty Big.
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.