-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_display.rkt
50 lines (41 loc) · 1.11 KB
/
show_display.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(require racket/trace)
(require rackunit)
; lists
; (check-equal? (function variable(s)) desired result)
; longer but with detailed show and display
(define (same-arg-twice fn y)
(show "outer")
(display "outer y ")
(show y)
(lambda (arg)
(show "inner")
(display "inner y ")
(show y)
(fn arg y))
)
(show 'preexecute)
(define square (same-arg-twice (lambda (x yi)
(display "innnerest x ")
(show x)
(display "innerest yi ")
(show yi)
(* x yi))
7))
(show 'postexecute)
(square 5)
(square 7)
(square 9)
; using trace-define and trace-lambda
(trace-define (same-arg-twice fn y)
(trace-lambda #:name innner (arg)
(fn arg y))
)
(show 'preexecute)
(define square (same-arg-twice (trace-lambda #:name innerest (x yi)
(* x yi))
7))
(show 'postexecute)
(square 5)
(square 7)
(square 9)
((trace-define-syntax 'ab (lambda (x y) (* x y))) 5 4)