[racket] About genericity...
I wanted to try it out, but it’s giving me an error about car expecting a pair:
. . car: contract violation
expected: pair?
given: #<flat-contract: (listof vector?)>
#lang racket
(require (submod def-multi/def-multi multim))
(require plot/utils)
(require (only-in racket [+ rkt:+]))
(require rackunit)
(def-multi +)
(add-multi + '() (lambda () 0))
(add-multi + (listof number?) (lambda args (apply + args)))
(add-multi + (listof vector?) (lambda args (apply v+ args)))
(check-equal? (+ 1 2 3) 6)
(check-equal? (+ (vector 1 2 3)
(vector 2 3 4)
(vector 3 4 5))
(vector 6 9 12))
On Apr 4, 2014, at 11:23 AM, Patrick Useldinger <uselpa.list at gmail.com> wrote:
> On 02/04/2014 20:48, Patrick Useldinger wrote:
>
>> I can share it if you're interested, it's roughly 40 lines of code.
>
> Here's the link: https://github.com/uselpa/def-multi
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users