I'm trying to learn how to estimate memory complexity of certain functions. And now I'm having a problem with one peculiar case.
So let's say we're building a function, something like this:
let f x = (fun x -> x :: [1;2;3]);;
And we're never calling this function, we're only composing it with another function at some point using this:
let compose f g x = f (g x);;
So the question is - how much space does f require before calling it and after calling compose on it? In order to make this question more general, when f builds n-sized array, but is not called, does it still take O(n) space or maybe it starts taking this space after calling it?