In the following generic code:
nat = [1..xmax] xmax = *insert arbitrary Integral value here* setA = [2*x | x <- nat] setB = [3*x | x <- nat] setC = [4*x | x <- nat] setD = [5*x | x <- nat] setOne = setA `f` setB setTwo = setC `f` setD setAll = setOne ++ setTwo setAllSorted = quicksort setAll
(note that 'f' means a function like
f :: Integral a => [a] -> [a] -> [a]
not just ++)
How does Haskell handle the attempt to print setAllSorted?
Does it get the values for setA and setB, compute setOne, and then store the values for setOne in memory (before calculating everything else)?
Or does Haskell store everything in memory until it gets the value for setAllSorted?
If so, then how would I indicate (using main, do functions and all those other IO objects) what does it do instead?
Can I tell the program in what order to collect and collect garbage? If so, how do I do this?
source share