Skip to content

Instantly share code, notes, and snippets.

@wilbowma
Created May 20, 2014 17:40
Show Gist options
  • Save wilbowma/cb037265e7aa054d29bb to your computer and use it in GitHub Desktop.
Save wilbowma/cb037265e7aa054d29bb to your computer and use it in GitHub Desktop.
#lang racket
(module+ test
(require racket/trace
rackunit)
(let ([x (current-output-port)])·
(current-trace-notify (lambda (s)
(display s x)
(newline x))))
(trace-define (verbose-fact x)
(if (zero? x)
(begin (display 1) 1)
(begin (display (* x (verbose-fact (sub1 x))))
(* x (verbose-fact (sub1 x))))))
(with-output-to-file "/tmp/meow" (thunk (verbose-fact 5)) #:exists
'replace)
(check-not-equal? (with-input-from-file "/tmp/meow" read) ">"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment