brokenix, 3 months ago when you reverse a list in #haskell aux_reverse [] out = out aux_reverse (x:xs) out = aux_reverse xs (x:out)<br></br>reverse l = aux_reverse l []<br></br> does it keep the reference to the original list (using max space) ? ll #ocaml do the same?
when you reverse a list in #haskell
aux_reverse [] out = out aux_reverse (x:xs) out = aux_reverse xs (x:out)<br></br>reverse l = aux_reverse l []<br></br>
does it keep the reference to the original list (using max space) ? ll #ocaml do the same?
BoydStephenSmithJr, 3 months ago @brokenix It will keep it until the next GC sweep, and that will keep it only if it is referenced elsewhere. Of course laziness can complicate that a little bit -- but reducing reverse list to WHNF does release the closure's reference to list (and reverse).
@brokenix It will keep it until the next GC sweep, and that will keep it only if it is referenced elsewhere.
Of course laziness can complicate that a little bit -- but reducing reverse list to WHNF does release the closure's reference to list (and reverse).
reverse list
list
reverse
Add comment