[Haskell-cafe] Large data structures

Stefan O'Rear stefanor at cox.net
Mon Dec 11 20:33:26 EST 2006


On Mon, Dec 11, 2006 at 10:27:44PM -0300, Alex Queiroz wrote:
> Hi all,
> 
>     I'm considering the use of Haskell to manipulate large data
> structures for Computer Graphics (large geometric datasets). I'm
> wondering what's the best way to do it. As "objects" (not in the OO
> sense) in Haskell are immutable, how can I add a vertex to a large
> mesh without using obscene amounts of memory? Making an analogy:
> 
> >enlarge :: a -> [a] -> [a]
> >enlarge c cs = c : cs
> >
> >enlarge 15 [1..100000]
> 
>     Will this copy the whole list to make a new one with an element more?

No.  Haskell's lists are linked lists, enlarge creates a single new link
without modifying (and copying) the original.


More information about the Haskell-Cafe mailing list