SV: Haskell-beginners problem with memory consuption

Petter Egesund petter.egesund at kunnskapsforlaget.no
Wed Oct 1 16:41:38 EDT 2003


Hi & thanks for answering;

I should have been more precise, my function works like this:

fun :: String -> String
	look for pat1 in string - if found subst with sub1
	look for pat2 in string - if found subst with sub2
	look for pat3 in string - if found subst with sub3
  recurse until no pattern is found

Cheers

PE

-----Opprinnelig melding-----
Fra: Wolfgang Jeltsch [mailto:wolfgang at jeltsch.net]
Sendt: 1. oktober 2003 15:36
Til: The Haskell Cafe
Emne: Re: Haskell-beginners problem with memory consuption


Am Mittwoch, 1. Oktober 2003, 15:18 schrieb Petter Egesund:
> [...]

> The problem is of course that the string is copied each time I do a
> substitute, and I wonder if a more experienced haskeller has a better
> solution to my problem.

It doesn't have to be a problem that the string is copied each time. If you 
have, e.g., functions
    f1, f2, ..., fn :: String -> String
and do something like
    f1 (f2 (... (fn string)...))
then string and the intermediate data can be removed by the garbage
collector 
as soon as they are not needed.

Unfortunately, from your message it's not very clear to me what exactly you 
mean, and, unfortunately again, I'm not an expert in Haskell memory 
management.

> I have myself considered these solutions, but they all seems non-elegant;
> [...]

Indeed, they all look very non-elegant, and I think, there is a better 
solution.

> Cheers,
>
> Petter Egesund

Wolfgang

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list