all
Lib.all : ('a -> bool) -> 'a list -> bool
Tests whether a predicate holds throughout a list.
all P [x1,...,xn]
equals
P x1 andalso .... andalso P xn
. all P []
yields true
.
If P x0,...,P x(j-1)
all evaluate to true
and P xj
raises an exception e
, then
all P [x0,...,x(j-1),xj,...,xn]
raises e
.
- all (equal 3) [3,3,3];
> val it = true : bool
- all (equal 3) [];
> val it = true : bool
- all (fn _ => raise Fail "") [];
> val it = true : bool
- all (fn _ => raise Fail "") [1];
! Uncaught exception:
! Fail ""