|
![](/i/fill.gif) |
Orchid XP v8 <voi### [at] dev null> 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.)
Maybe the problem is that in an imperative language the different
situations would be more explicitly expressed with an 'if...then...else'
block. Here it's not clear at all what is it that the code is expressing.
Of course it doesn't help that the syntax is quite uncommon, and the
meaning of the different operators isn't clear. (For instance, it's unclear
whether the ' is some kind of operator, and if it is, what exactly its role
is. If it isn't an operator but somehow just part of the variable name, it's
highly unusual.)
The lack of separators is also confusing to someone who is accustomed to
programming languages that use separators.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |