From 83455a2252ae7e5df1bf8a0c8e6f64e4247f28ee Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Tue, 2 Aug 2016 19:34:44 +0100 Subject: [PATCH] General-purpose functions --- Sat.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sat.hs b/Sat.hs index 39b9c50..fb0797d 100644 --- a/Sat.hs +++ b/Sat.hs @@ -36,6 +36,23 @@ type Assignment = [Lit] ---------------------------------------------------------------------- +-- General-purpose functions + +-- Extracts a variable from a literal +fromLit :: Lit -> Var +fromLit (Pos x) = x +fromLit (Neg x) = x + +-- Tests for positive/negative literals +isPos :: Lit -> Bool +isPos (Pos _) = True +isPos (Neg _) = False + +isNeg :: Lit -> Bool +isNeg = not . isPos + +---------------------------------------------------------------------- + -- Literal Evaluation -- Negates a literal