List 在Haskell new中打印列表
对haskell来说是全新的,我需要打印出包含在每个单独项目的单独一行中的数据 不确定如何List 在Haskell new中打印列表,list,haskell,printing,List,Haskell,Printing,对haskell来说是全新的,我需要打印出包含在每个单独项目的单独一行中的数据 不确定如何 type ItemDescr = String type ItemYear = Int type ItemPrice = Int type ItemSold = Int type ItemSales = Int type Item = (ItemRegion,ItemDescr,ItemYear,ItemPrice,ItemSold,ItemSales) type ListItems = [Item]
type ItemDescr = String
type ItemYear = Int
type ItemPrice = Int
type ItemSold = Int
type ItemSales = Int
type Item = (ItemRegion,ItemDescr,ItemYear,ItemPrice,ItemSold,ItemSales)
type ListItems = [Item]
rownumber x
| x == 1 = ("Scotland","Desktop",2017,900,25,22500)
| x == 2 = ("England","Laptop",2017,1100,75,82500)
| x == 3 = ("Wales","Printer",2017,120,15,1800)
| x == 4 = ("England","Printer",2017,120,60,7200)
| x == 5 = ("England","Desktop",2017,900,50,45000)
| x == 6 = ("Wales","Desktop",2017,900,20,18000)
| x == 7 = ("Scotland","Printer",2017,25,25,3000)
showall
--print??
例如,在每一行上
展示
“苏格兰”,“桌面”,2017900,2522500
然后是下一条记录提示1: 像这样存储数据
items = [("Scotland","Desktop",2017,900,25,22500),
("England","Laptop",2017,1100,75,82500),
("Wales","Printer",2017,120,15,1800),
("England","Printer",2017,120,60,7200),
("England","Desktop",2017,900,50,45000),
("Wales","Desktop",2017,900,20,18000),
("Scotland","Printer",2017,25,25,3000)]
提示2:
实现这个功能
toString :: Item -> String
toString = undefined -- do this yourselves
技巧3:
尝试组合以下功能
,已在序曲中取消线
,您刚刚编写了它toString
,不需要任何解释地图
,甚至不确定这是否是一个真正的函数,但您仍然需要它putStrLn
,你可以不用这个,但它会给你加分($)