我在編寫一個代碼,它接受dictionary
和array of keys
並檢查字典並查看該字符是否在字典中,如果不在字典中有離開它,否則發送回那些鍵和值,其關鍵字是傳遞字典並搜索一組值並在haskell中返回另一個字典
我穿,但我得到的代碼太多錯誤的字典詞典
let x = check dict key
putStrLn $ show (x)
check :: Eq k => [(k, v)] ->[k] -> [(k,v)]
check dict words = [findVal word dict | word <- words]
findVal :: (Eq k) => k -> [(k,v)] -> [(k, v)]
findVal key xs = foldr (\(k,v) acc -> case key == k of True -> (k,v)
False -> acc) xs
的錯誤是數據類型2個功能,而且這個cse也是一個錯誤
你得到了什麼錯誤? – mhwombat