From 42e5b4cc8b2dbd76ba4567b73967de974831c666 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 1 Sep 2011 12:58:37 -0400 Subject: [PATCH] Add the 'disjoint' function. --- src/Misc.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Misc.hs b/src/Misc.hs index 9dcbac9..b9220cb 100644 --- a/src/Misc.hs +++ b/src/Misc.hs @@ -3,6 +3,8 @@ module Misc where +import Data.List (intersect) + -- | The standard factorial function. See -- for @@ -57,3 +59,19 @@ all_equal xs = where first_element = head xs other_elements = tail xs + + +-- | Returns 'True' if the lists xs and ys are disjoint, 'False' +-- otherwise. +-- +-- Examples: +-- +-- >>> disjoint [1,2,3] [4,5,6] +-- True +-- +-- >>> disjoint [1,2,3] [3,4,5] +-- False +-- +disjoint :: (Eq a) => [a] -> [a] -> Bool +disjoint xs ys = + intersect xs ys == [] -- 2.43.2