PasteRack.org
Paste # 14071
2018-11-02 13:50:48

Fork as a new paste.

Paste viewed 2164 times.


Embed:

  1. (define (insert-into-binary-tree value btn)
  2.   (cond
  3.     [(empty? btn)
  4.        (make-binary-tree-node value empty empty)
  5.        ]
  6.     [(empty? (binary-tree-node-value btn))
  7.        (make-binary-tree-node value empty empty)
  8.        ]
  9.     [(= value (binary-tree-node-value btn))
  10.        btn
  11.        ]
  12.     [(< value (binary-tree-node-value btn))
  13.        (make-binary-tree-node (binary-tree-node-value btn) (insert-into-binary-tree value (binary-tree-node-left btn)) (binary-tree-node-right btn))
  14.        ]
  15.     [else
  16.        (make-binary-tree-node (binary-tree-node-value btn) (binary-tree-node-left btn) (insert-into-binary-tree value (binary-tree-node-right btn)))
  17.        ]
  18.   )
  19. )
  20.  
  21. ;; Here starts the interesting part
  22. (define (binary-tree-from-reversed-list lst)
  23.   (cond
  24.     [(empty? lst) false]
  25.     [(empty? (rest lst)) (insert-into-binary-tree (first lst) empty)]
  26.     [else (insert-into-binary-tree (first (rev-lst lst)) (binary-tree-from-reversed-list (rest (rev-lst lst))))]
  27.   )
  28. )
  29.  
  30. (define (rev-lst lst)
  31.   (reverse lst)
  32. )

=>

load-handler: expected a `module' declaration for `pasterack' in "paste 14071", but found something else

Check that paste includes #lang?