【发布时间】:2012-07-16 19:51:09
【问题描述】:
我的程序是在元组列表中搜索我写的如下
import List
data BookInfo = Book Int String [String]
deriving(Show)
enter :: Int->String->[String]->BookInfo
enter id name subject=Book id name subject
bookId (Book id _ _ ) = id
index :: BookInfo -> Int
index (Book id name subject) = bookId (Book id name subject)
arrayentering ::BookInfo->[BookInfo]->[BookInfo]
arrayentering (Book id name subject) [] =[(Book id name subject)]
arrayentering (Book _ " " [" "]) [] =[]
arrayentering (Book id name subject) [(Book it namr suject)]=
(Book id name subject):[(Book it name suject)]
toList::[BookInfo]->[Int]
toList [(Book id name subject) ]= map index [ (Book id name subject)]
bubbleSort::(Ord t) => [t]->[t]
bubbleSort[x,y,z,xs]=
if x<y then x : [y,z,xs]
else y : [x,z,xs]
superBubble::(Ord t) => [[t]]->[[t]]
superBubble a=map bubbleSort a
combining::[BookInfo]->[[Int]]
combining [(Book id name subject)]=superBubble [toList [(Book id name subject)]]
并从任何语法错误中清除它,但是在我尝试输入到 combining() 的元组列表之后,它给了我运行时错误说
Exception:Not Exhaustive pattern in function Main.combining
这是什么意思?
请给我一些指示。如果可能的话,我想自己修复它。
【问题讨论】:
-
+1 因为不想给你答案
标签: haskell tuples runtime-error