Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Created June 12, 2013 18:36
Show Gist options
  • Save grauwoelfchen/5767887 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/5767887 to your computer and use it in GitHub Desktop.
(define t-pre-order
(lambda (t)
(if (t-empty? t)
'()
(append (list (t-value t))
(t-pre-order (t-left t))
(t-pre-order (t-right t)))) ))
(define t-pre-order-r
(lambda (t)
(let aux ([t t] [res '()])
(cond
[(t-empty? t) res]
[#t
(aux t-empty
(cons (t-value t)
(aux (t-left t)
(aux (t-right t) res))))])) ))
(printf "pre-order : ~s~n" (t-pre-order my-tree))
(printf "pre-order : ~s~n" (t-pre-order-r my-tree))
@grauwoelfchen
Copy link
Author

😢

optimizer: warning in: /path/to/workspace/.learn/scheme/btree.rkt:72:4: aux in module: 'btree: constant-fold attempt failed: car: contract violation
  expected: pair?
  given: #f
optimizer: warning in: /path/to/workspace/.learn/scheme/btree.rkt:72:4: aux in module: 'btree: constant-fold attempt failed: cadr: contract violation
  expected: (cons/c any/c pair?)
  given: #f
optimizer: warning in: /path/to/workspace/.learn/scheme/btree.rkt:72:4: aux in module: 'btree: constant-fold attempt failed: caddr: contract violation
  expected: (cons/c (cons/c any/c pair?) any/c)
  given: #f
optimizer: warning in: /path/to/workspace/.learn/scheme/btree.rkt:72:4: aux in module: 'btree: constant-fold attempt failed: car: contract violation
  expected: pair?
  given: #f
optimizer: warning in: /path/to/workspace/.learn/scheme/btree.rkt:72:4: aux in module: 'btree: constant-fold attempt failed: cadr: contract violation
  expected: (cons/c any/c pair?)
  given: #f
optimizer: warning in: /path/to/workspace/.learn/scheme/btree.rkt:72:4: aux in module: 'btree: constant-fold attempt failed: caddr: contract violation
  expected: (cons/c (cons/c any/c pair?) any/c)
  given: #f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment