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: Darren New
Date: 5 Sep 2011 17:03:01
Message: <4e653905$1@news.povray.org>
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.

-- 
Darren New, San Diego CA, USA (PST)
   How come I never get only one kudo?


Post a reply to this message

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