On Tue, Aug 5, 2014 at 5:06 PM, Jens Axel Søgaard <jensa...@soegaard.net>
wrote:

> What happens in create-bst-word, when the word to inserted is the same
> as (node-word bst) ?


Aha! I see. It returns void because there is no case for when the string is
equal.

> (void? (create-bst-word (create-bst-word false "dan") "dan"))
#t

I patched it with an else-case now.

(define (create-bst-word bst str)
  (cond
   ((false? bst)
    (make-node str false false))
   ((string<? str (node-word bst)) ;; insert at the left
    (make-node (node-word bst)
               (create-bst-word (node-left bst) str)
               (node-right bst)))
   ((string>? str (node-word bst)) ;; insert at the right
    (make-node (node-word bst)
               (node-left bst)
               (create-bst-word (node-right bst) str)))
   (else (make-node (node-word bst)
                    (node-left bst)
                    (node-right bst)))))

> (void? (create-bst-word (create-bst-word false "dan") "dan"))
#f

Thank you.
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to