linfo2335-programming-parad.../project-2/step0.bak

17 lines
419 B
Plaintext
Raw Normal View History

2024-04-26 23:07:23 +02:00
(define (point x y)
(define (dispatch m)
(cond ((eq? m 'getx) x)
((eq? m 'gety) y)
((eq? m 'type) 'point)
((eq? m 'info) (list 'point x y))
(else (display (string-append "point as no method: " (symbol->string m) "\n")))))
dispatch)
(define p (point 1 2))
(p 'getx) ; 1
(p 'gety) ; 2
(p 'type) ; point
(p 'info) ; (point 1 2)
(p 'foo) ; display "point as no method: foo