mit-scheme-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tracing a procedure defined in a closure?


From: Nicholas Papadonis
Subject: Tracing a procedure defined in a closure?
Date: Thu, 19 Mar 2020 22:04:58 -0400

Does anyone know how to trace functions defined in a closure, without having to add (trace proc) into the closure?

For instance, this does not trace:
(define (hanoi n)
  (define (pmd from to)
    (display "Move ")
    (display from)
    (display " to ")
    (display to)
    (newline)
    '())
  (define (hanoi-move n from to spare)
    (cond ((= n 0) '())
 ((= n 1) (pmd from to))
 (else
  (hanoi-move (- n 1) from spare to)
  (hanoi-move 1 from to spare)
  (hanoi-move (- n 1) spare to from))))
  (hanoi-move n "A" "B" "C"))
;Value: hanoi

(trace hanoi-move)
;Unspecified return value

(hanoi 2)
Move A to C
Move A to B
Move C to B
;Value: ()

Inserting (trace hanoi-move) to (define (hanoi) ... ) and the trace works.

Thanks


reply via email to

[Prev in Thread] Current Thread [Next in Thread]