如何在haskell中将用户定义的数据用作参数?
我是哈斯克尔的新手 我有这个计划:如何在haskell中将用户定义的数据用作参数?,haskell,Haskell,我是哈斯克尔的新手 我有这个计划: loop height weight=do line<-getLine if line=="1" then do height<-getLine loop height weight else if line=="2" then do weight<-getLine loop height
loop height weight=do
line<-getLine
if line=="1" then
do
height<-getLine
loop height weight
else if line=="2" then
do
weight<-getLine
loop height weight
else if line=="3" then
do
putStrLn (height)
else
do
putStrLn "error"
main :: IO ()
main = do
loop "" ""
loop height weight=do
行您可以使用记录更新表示法:
if line=="1" then
do
height'<-getLine
loop z{height = height'}
如果行==“1”,则
做
高度'您可以使用记录更新表示法:
if line=="1" then
do
height'<-getLine
loop z{height = height'}
如果行==“1”,则
做
高度'