//当我只使用这 2 行时编辑 5
index :: [String] -> [String] -> Bool
index a b = and [x `elem` a |x <- b]
它工作正常!!!!
例如:
索引 ["asd","asdd","dew"] ["asdd","asdad"]
错误的
但是当我使用下面提到的整个代码时
empty [] = True
empty _ = False
index a b = do
if empty a
then do putStrLn "a is empty"
else return ()
if empty b
then do putStrLn "b is empty"
else return ()
where
index :: [String] -> [String] -> Bool
index a b = and [x `elem` a |x <- b]
没有输出!!这就是我遇到的问题!
//编辑 6
index a b = do index'
if empty a
then do putStrLn "a is empty"
else return ()
if empty b
then do putStrLn "b is empty"
else return ()
where
index' :: [String] -> [String] -> Bool
index' a b = and [x `elem` a |x <- b]
谢谢