PasteRack.org
Paste # 72687
2018-03-13 15:24:00

Fork as a new paste.

Paste viewed 244 times.


Embed:

  1. #lang racket
  2.  
  3. (define t '(10 (5(4(2 ()()) (22()())) (21(15()()) (23 ()()))) (11(6()())(13()()))))
  4.  
  5. (define (leaf? t)
  6.    (and(null?(cadr t)) (null? (caddr t))))
  7. (leaf? t)
  8.  
  9. (define (tree-max t)
  10.   (if (null? t)
  11.       '()
  12.       ((leaf? t)(tree-max (caddr t)))))
  13.  
  14. (tree-max t)

=>

#f

application: not a procedure;

 expected a procedure that can be applied to arguments

  given: #t

  arguments...:

   '()