Re: Binary search tree

2002-04-29 Thread Rijk J. C. van Haaften
Hi everybody, I studied haskell this semester at the university and I was required to implement a binary search tree in haskell. I would appreciate if anyone could send me an example code of this data structure. Just read a standard textbook. Some useful course notes by Jeroen Fokker are

RE: Binary Search Tree debugging

2000-04-19 Thread Mark P Jones
Hi Andrew, | Hey all.. I was wondering if somebody might offer me some assistance in | trying to debug some code I wrote to check whether a tree is a binary | search tree.. For some reason it always comes back as false! :( Thanks | much! One of the great things about functional programming is

Re: Binary Search Tree debugging

2000-04-18 Thread Marcin 'Qrczak' Kowalczyk
Mon, 17 Apr 2000 14:47:49 -0400 (EDT), Sitzman [EMAIL PROTECTED] pisze: | otherwise = False 2 / should be a BST too. 1 checkL = ((treeVal (leftSub thetree)) (treeVal (thetree))) checkR = ((treeVal (rightSub thetree)) (treeVal (thetree))) It's not enough: 3 / \ 2

Re: Binary Search Tree debugging

2000-04-18 Thread Malcolm Wallace
Assuming this isn't a homework exercise... 1) If current node is empty then this portion of tree is a BST 2) if the left subtree and right subtree's are both not empty then ... The logical negation of your second clause (which is what is picked up by the 'otherwise' clause of your code) is

Re: binary search

1998-04-18 Thread Adrian Hey
On Fri 17 Apr, Dave Tweed wrote: On Thu, 16 Apr 1998, S. Alexander Jacobson wrote: All that being said, we can say that there are certain properties that all haskell functions must fulfill. For example a recursive function should never call itself with the arguments that it recieved.

Re: binary search

1998-04-17 Thread Dave Tweed
On Thu, 16 Apr 1998, S. Alexander Jacobson wrote: All that being said, we can say that there are certain properties that all haskell functions must fulfill. For example a recursive function should never call itself with the arguments that it recieved. e.g. myFunction 2 3 should not make

Re: binary search

1998-04-17 Thread Simon L Peyton Jones
Not to reject assertions (they would be welcome), but I think that you need something slightly different in a functional programming language. Assertions in procedural languages typically define system state before and after a particular function gets executed. State assertions are less

Re: binary search

1998-04-17 Thread Alex Ferguson
Various people write: Cc: [EMAIL PROTECTED], [EMAIL PROTECTED] Can I ask people to be careful to which haskell-list address(es) they followup to? My understanding is that list messages ought to be sent _only_ to [EMAIL PROTECTED], and that any other addresses are symptoms (and in some cases

Re: binary search

1998-04-16 Thread Simon L Peyton Jones
2. how would I have found/fixed such an error in a more complex function w/o assertions and w/o print statements? Good questions There was a proposal to put assertions into Std Haskell, which we have implemented in GHC. (I'm not sure we've yet put that version out though.) So

Re: binary search

1998-04-16 Thread S. Alexander Jacobson
On Thu, 16 Apr 1998, Simon L Peyton Jones wrote: 2. how would I have found/fixed such an error in a more complex function w/o assertions and w/o print statements? Good questions There was a proposal to put assertions into Std Haskell, which we have implemented in GHC. (I'm not