9.0
top
← prev up next →

HTDP TraceπŸ”— i

djholtby

Racket has a useful tracing tool. Unfortunately it does not work in Beginning Student. This package provides a wrapper that can be used in the HtDP Languages.

syntax

( define/trace (nameparam...)body)

Behaves the same as define , but whenever the function name is applied, the values of its parameters will be printed to the screen. When the function produces a value, that value will also be printed.

Examples:
(require htdp-trace)
(+ 2x))
(f2)

>(f 2)

<4

4

(define/trace (sum-numsn)
(cond [(zero? n)0]
[else (+ n(sum-nums(- n1)))]))
(sum-nums3)

>(sum-nums 3)

> (sum-nums 2)

> >(sum-nums 1)

> > (sum-nums 0)

< < 0

< <1

< 3

<6

6

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /