Add files via upload
This commit is contained in:
commit
fb6dd81f33
17 changed files with 735 additions and 0 deletions
22
Ternary/Universum.hs
Normal file
22
Ternary/Universum.hs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
module Ternary.Universum (Universum(..), universum, aFromStatements) where
|
||||
import Data.List (nub)
|
||||
import Ternary.Term (Item (..), Term (..), Vee)
|
||||
|
||||
data Universum = Aristotle
|
||||
| Empty
|
||||
| Default
|
||||
|
||||
universum :: (Eq a) => Universum -> [Vee a] -> [Vee a]
|
||||
universum Aristotle facts =
|
||||
[Term True (Item [Term x v])
|
||||
| v <- aFromStatements facts,
|
||||
x <- [False, True]]
|
||||
universum Empty _ = []
|
||||
universum Default xs = xs
|
||||
|
||||
aFromStatements :: (Eq a) => [Vee a] -> [a]
|
||||
aFromStatements = nub . concatMap (extract . getItem . getVee)
|
||||
where
|
||||
getItem (Item x) = x
|
||||
getVee (Term _ i) = i
|
||||
extract terms = [v | (Term _ v) <- terms]
|
||||
Loading…
Add table
Add a link
Reference in a new issue