wiki:Functions/Every

every, all

(define every? (lambda (f? xs)
                   (if (null? xs)
                       #t
                       (and (f? (car xs)) (every f? (cdr xs))))))
all _ []      =  True
all p (x:xs)  =  p x && all p xs
all p  =  and . map p
all(Pred, [H|T]) ->
    case Pred(H) of
        true -> all(Pred, T);
        false -> false
    end;
all(Pred, []) when is_function(Pred, 1) -> true. 
Last modified 3 years ago Last modified on Nov 2, 2016, 5:13:40 PM
Note: See TracWiki for help on using the wiki.