Q:

Lisp Program producing contract violation

I wrote a lisp program that takes two parameters, a destination, and a map in the form of a BST. It searchings the BST for the destination number, and prints (found: path) if the destination is found. If it's not found, it's supposed to print (not found: destination), but for some reason I am getting a contract violation. It's not running through my cond correctly, and I have been messing with it for thirty minutes. Can anyone help.
Here is my program:
(define (robot goal map)
  [code hidden for university honour code purposes]

; Test robot function
(robot 64 '(53 () (64 () ())))
(robot 4 '(53 () (64 () ())))

A:

You're missing one case in the procedure (define (robot map path) ...) . What happens if the map parameter is null? fix it like this:
(define (robot map path)
  (cond ((not (null? map))
         [code hidden for university honour code purposes])
        (else '()))) ; this line was missing!

It's exactly the same thing that I mentioned in my answer to your previous question: always the first case to consider, whether you're traversing a list or a tree, is: what happens if it's null?

