Next: Numbers Up: Basic Data Extensions Previous: Void and Undefined

# Booleans

Unless otherwise specified, two instances of a particular MzScheme data type are `equal?` only when they are `eq?`.

The `andmap` and `ormap` procedures apply a test procedure to the elements of a list, returning immediately when the result for testing the entire list is determined. The arguments to `andmap` and `ormap` are the same as for `map`, but a single Boolean value is returned as the result rather than a list:

- `(andmap proc list )` applies proc to elements of the lists from the first elements to the last, returning `#f` as soon as any application returns `#f`. If no application of proc returns `#f`, then the result of the last application of proc is returned. If the lists are empty, then `#t` is returned.
- `(ormap proc list )` applies proc to elements of the lists from the first elements to the last. If any application returns a value other than `#f`, that value is immediately returned as the result of the `ormap` application. If all applications of proc return `#f`, then the result is `#f`. If the lists are empty, then `#f` is returned.

Examples: ``

      (andmap positive? '(1 2 3)) ; => #t
      (ormap eq? '(a b c) '(a b c)) ; => #t
      (andmap positive? '(1 2 a)) ; => raises exn:application:type
      (ormap positive? '(1 2 a)) ; => #t
      (andmap positive? '(1 -2 a)) ; => #f
      (andmap + '(1 2 3) '(4 5 6)) ; => 9
      (ormap + '(1 2 3) '(4 5 6)) ; => 5