formatBill :: BillType -> String
formatBill bill = merge' [pname ++ dots ++ show pprice | (pname, pprice) <- bill]
where
dots = ['.' | x<-[1..(lineLength - length pname - length (show pprice))]]
Run Code Online (Sandbox Code Playgroud)
这是我的代码 - formatBill是一个必须返回的函数String.
它应该返回的一个例子:
Product name.................. PRICE
Other product................. 4555
Run Code Online (Sandbox Code Playgroud)
merge' 只是 [String] -> String
type BillType = [(String, Int)] -- BillType definition
lineLength = 30 -- length of row
Run Code Online (Sandbox Code Playgroud)
这些是我得到的错误:
code.hs:69:51:不在范围内:`pname'
code.hs:69:72:不在范围内:`pprice'
haskell ×1