Created
June 10, 2014 16:35
-
-
Save soegaard/6223a11ebbf42c5f1c97 to your computer and use it in GitHub Desktop.
Polymorphic +
This file contains hidden or 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 | |
(require math | |
(prefix-in racket: racket)) | |
(define (+ . xs) | |
(cond | |
[(andmap number? xs) (apply racket:+ xs)] | |
[else (apply matrix+ xs)])) | |
(+ (matrix [[1 2] [3 4]]) | |
(matrix [[5 6] [7 8]])) | |
(+ 41 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment