我希望用戶進入元組的列表就可以了搜索鍵這樣我可以說像這樣繼續輸入元組
data BookInfo = Book Int String [String]
deriving(Show)
findbook :: [BookInfo] -> Int -> BookInfo
findbook vs key = (booker (vs!!(bookFinding vs key 0 (length vs))) key)
getBookInfo = do
putStrLn "Enter book id :"
k <- read
putStrLn "Enter book name : "
r <- getLine
putStrLn "Enter book subject :"
m <- getLine
let Book book = enter k r [m]
return book
main = do
putStr "Enter you first info is :"
v <- getBookInfo
let Book vs = v:[]
c <- getLine
if c == "N"
then
putStr "You done"
else
Book booke = getBookInfo
vs = booke:vs
putStr "Do you want to search ? :"
m <- getch
if m == 'y'
then
putStr " Enter your key :"
s <- readNum
let Book w = findBook vs s
putStrLn" The result is: " ++ show(w)
但它給我一個錯誤:
The last statement in do must be m <- getch
我在做什麼錯?
您是否嘗試修理您的縮進? – fuz 2012-07-21 21:26:00
首先,每個'if'必須有'else'子句。你最後的'if'沒有。 – 2012-07-21 21:38:57
好吧,我只是花了幾分鐘的時間來修復你的代碼。我的結論是,此刻,這是一個完整的混亂。什麼是「booker」,「bookFinding」和「enter」函數? – 2012-07-21 21:45:04