如何通过仅键入一次来同时从 2 个 .txt 文件中执行 2 func(减法和求和)来获取 l?可以使用任何更高阶的功能吗?感谢您的帮助。
transfer :: IO()
transfer = do
k <- readFile "balance1.txt"
b <- readFile "balance2.txt" --------read the second file------
putStrLn "The amount that need to transfer"
l <- getLine
let n = read l::Int
let a = read k::Int
let c = read b::Int
if ( n < a )
then do
let o = a - n
let d = show o
let e = n + c
putStrLn "Your new balance is"
putStrLn(d)
writeFile "balance1.txt" d -----------modify 1st file--------
writeFile "balance2.txt" e -----------modify 2nd file--------
else do
putStrLn "Amount is not valid"