On 05/04/2014 00:08, Patrick Useldinger wrote:
I copied Common Lisp's model, but it's a good idea to add Racket-style
contracts. It should be a matter of simply adding a matcher for this.

I've pushed a quick fix. Your code becomes:

(def-multi P contract-match-parms)
(add-multi P (listof number?) (lambda args (apply + args)))
(add-multi P (listof vector?) (lambda args (apply v+ args)))

(check-equal? (P 1 2 3) 6)
(check-equal? (P (vector 1 2 3) (vector 2 3 4)) (vector 3 5 7))

I dropped the default method you created ((add-multi + '() (lambda () 0)) ) because I don't see why you'd need it for, and it prevents proper error messages in case no method matches.

Regards,
-Patrick
____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to