-
-
Save 97jaz/fda5e459d1181126bc1b6681092ee596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/generic) | |
(define-generics print | |
(gen-print print)) | |
(define (print-point p) | |
(format "x is ~a" (point-x p))) | |
(struct | |
point (x) | |
#:methods gen:print | |
[(define gen-print print-point)]) | |
(struct | |
point2d point (y) | |
#:methods gen:print | |
[(define (gen-print me) | |
(format "~a && y is ~a " (print-point me) (point2d-y me)))]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment