level 1
请问haskell做到这个么把每个输入的字符串,合成一个字符串么?
比如第一次,我输入h,第二次我输入i
能出来hi么?如果能这个方程怎么写
2014年03月27日 10点03分
1
level 1
loop s=do
input<-readStrLn
let next=s ++ input
putStrLn next
loop next
main=loop ""
2015年02月14日 08点02分
9
level 3
main = interact $ foldr (++) "" . lines
lines 把输入根据换行分割成列表。
foldr (++) "" 把一组字符串连接起来。
当然这段代码必须指定不同的输入输出文件,你单纯在终端执行的话,输入和输出会混在一起。
2015年03月18日 16点03分
10
是的
2015年03月18日 23点03分