POV-Ray : Newsgroups : povray.off-topic : My hypothesis : Re: My hypothesis Server Time
29 Jul 2024 14:16:34 EDT (-0400)
  Re: My hypothesis  
From: Warp
Date: 5 Sep 2011 17:36:54
Message: <4e6540f6@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> On 9/5/2011 11:45, Warp wrote:
> > Orchid XP v8<voi### [at] devnull>  wrote:
> >>     insert :: Ord x =>  x ->  MinHeap x ->  MinHeap x
> >>     insert x' (Leaf        ) = Node x' Leaf Leaf
> >>     insert x' (Node x h0 h1) = Node (min x x') (insert (max x x') h1) h0
> >
> >    This is a good example of where it becomes confusing. Even after
> > studying it for a few minutes I can't really figure out what is it
> > that it's doing. (Or, more precisely *how* it's doing it. The 'insert'
> > name makes it obvious what is it that it does, but the code doesn't make
> > it at all clear how.)

> I think part of it may be that you're thinking "insert" actually inserts 
> something in the heap. Nope! "insert" is a function that when given a value 
> and a heap, gives you back the new heap you would have were you to insert 
> that given value into that given heap.

  What happens to the old heap?

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.