Skip to content

Instantly share code, notes, and snippets.

@soegaard
Created June 10, 2014 16:35
Show Gist options
  • Save soegaard/6223a11ebbf42c5f1c97 to your computer and use it in GitHub Desktop.
Save soegaard/6223a11ebbf42c5f1c97 to your computer and use it in GitHub Desktop.
Polymorphic +
#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