schemechez-scheme

Andmap\ormap - chez scheme


I tried to find information about andmap & ormap operations in chez scheme.

Still, I don't understand the use of these operations, and what is the difference between it and map.


Solution

  • In pseudo-Scheme,

    (andmap f xs)  ==  (fold and #t (map f xs))
    (ormap  f xs)  ==  (fold or  #f (map f xs))
    

    except that:

    1. You can't use and and or in this way.
    2. andmap and ormap can short-circuit processing the list.

    That is, except for slightly different short-circuiting behavior,

    (andmap f (list x1 x2 x3 ...))  ==  (and (f x1) (f x2) (f x3) ...)
    (ormap  f (list x1 x2 x3 ...))  ==  (or  (f x1) (f x2) (f x3) ...)