(import match-generics) (define-generic (frotz a b c) (list b a c)) (define-generic (frotz x y) (+ x y)) (unless (equal? '((2 1 3) 9) (list (frotz 1 2 3) (frotz 4 5))) (error "(list (frotz 1 2 3) (frotz 4 5))")) (define-generic (my-map proc (x . xs)) (cons (proc x) (my-map proc xs))) (define-generic (my-map proc ()) '()) (unless (equal? '(2 3 4) (my-map add1 '(1 2 3))) (error "(my-map add1 (quote (1 2 3)))")) (define-generic (plus (? list? a) (? list? b)) (append a b)) (define-generic (plus (? string? a) (? string? b)) (string-append a b)) (define-generic (plus (? number? a) (? number? b)) (+ a b)) (unless (equal? '("1314" 29 32 (a b c 1 2 3)) (list (plus "13" "14") (plus 7 22) (plus 13 19) (plus '(a b c) '(1 2 3)))) (error "(list (plus \"13\" \"14\") (plus 7 22) (plus 13 19) (plus (quote (a b c)) (quote (1 2 3))))")) (define-generic ((frobnicate a) b z) (list a b z)) (define-generic ((frobnicate a) b) (string-append a b)) (unless (equal? '(("hoho" 1 2) "hoho and such") (let ((hoho (frobnicate "hoho"))) (list (hoho 1 2) (hoho " and such")))) (error "(let ((hoho (frobnicate \"hoho\"))) (list (hoho 1 2) (hoho \" and such\")))"))