
Hello Awsaf,
you should probably look further into the topic of "IO in Haskell" and
"Monads". Then you can use impure functions like readFile
(http://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:readFil... ) or getArgs (http://hackage.haskell.org/package/base-4.11.1.0/docs/System-Environment.htm...). A naive solution might look like
this:
module Main where
import System.Environment (getArgs)
main = do
(fileName:_) <- getArgs
unsortedList <- read <$> readFile fileName
let sorted = yourMergeSortFunction unsortedList
print sorted -- maybe you like to print your sorted list
Best regards,
Tobias
----- Nachricht von Awsaf Rahman
Hello everyone! I am really struggling with Haskell I/O. I have written a mergesort program and as an input to that program I want to use a file containing a list of 1000 integers. Let's say the contents of the file look like this [120, 400, 500 , 20, 100 ..] How can I achieve that? I am trying to write a main function that takes the file as an input and passes the list to my mergesort function.. Regards Awsaf Rahman
----- Ende der Nachricht von Awsaf Rahman