On this page:
Bool
true
false
if
not
and
or
bool->meta-bool
meta-bool->bool
7.7

3.3 Bool

This library defines the datatype Bool and several functions and forms for using them.

0 parameter type

Bool : Type

constructor

true : Bool

constructor

false : Bool

The boolean datatype.

syntax

(if test-expr c-expr alt-expr)

A syntactic form that expands to the inductive eliminator for Bool. This form is currently non-dependent—the branches do not know that test-expr is equal to true or false.

Examples:
> (if true false true)

(false)

> (elim Bool (λ (x : Bool) Bool) (false true) true)

(false)

procedure

(not x)  Bool

  x : Bool
Negates the boolean x.

Examples:
> (not true)

(false)

> (not false)

(true)

procedure

(and x y)  Bool

  x : Bool
  y : Bool
The boolean and. True if and only if x and y are both either true or false.

Examples:
> (and true true)

(true)

> (and false true)

(false)

procedure

(or x y)  Bool

  x : Bool
  y : Bool
The boolean or. True if and only if either x or y is true.

Examples:
> (or true true)

(true)

> (or false true)

(true)

> (or false false)

(false)

procedure

(bool->meta-bool syn)  boolean?

  syn : syntax?
A meta-procedure, provided at phase 1, that converts syntax representing a Bool literal into a Racket (meta-level) boolean?.

Example:

procedure

(meta-bool->bool b)  syntax?

  b : boolean?
A meta-procedure, provided at phase 1, that converts a Racket (meta-level) boolean? into syntax representing a Bool.

Example:
> (begin-for-syntax
    (displayln (meta-bool->bool #f)))

#<syntax:/home/root/user/.racket/7.7/pkgs/cur-lib/cur/stdlib/bool.rkt:38:19 false>