-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
22 lines (16 loc) · 857 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Main where
import Query
import Data.List
anyE :: (a -> Bool) -> [a] -> Bool
anyE f [] = True
anyE f xs = any f xs
traverse :: String -> Query -> Bool
traverse s (BooleanQuery xs) = (all (traverse s) [q | Clause And q <- xs ]) &&
(anyE (traverse s) [q | Clause Or q <- xs ]) &&
not (any (traverse s) [q | Clause Not q <- xs ])
traverse s (PhraseQuery ws) = (unwords . reverse) ws `isInfixOf` s
traverse s (TermQuery t) = t `elem` words s
--expl :: Query -> Bool
--expl (BooleanQuery xs) = all (traverse s) [q | Clause And q <- xs ] && any (traverse s) [q | Clause Or q <- xs ] && not all (traverse s) [q | Clause Not q <- xs ]
main =
--print $ traverse "vado a malpensa e anche a linate" (parse " (malpensa linate) +\"anche ah\" ")