i have a dynamic txt file example (1,1,1), im trying to read them from file to pass them to problem function.
function problem :: Int->Int->Int->[Int]
args <- getArgs
contents <- readFile (head args)
let value = read contents::(Int,Int,Int)
//print(show(problem 1 1 1))
print(show(problem value))
Couldn't match expected type ‘Int’ with actual type ‘(Int, Int, Int)’
CodePudding user response:
You need to extract the three Int
values in order to pass them individually to problem
.
let (a, b, c) = read contents :: (Int, Int, Int)
print (show (problem a b c))
Conversely, you could define an uncurry3
function to adapt problem
to work with a tuple.
uncurry3 :: (a -> b -> c -> d) -> ((a, b, c) -> d)
uncurry3 f = \(x,y,z) -> f x y z
print (show ((uncurry3 problem) value))