22 Avr
2013
22 Avr
'13
10:39
Clearly, there could be more features and it could be more efficient, but in terms of producing the simplest thing that works for me, I'm really happy with this: https://gist.github.com/eraserhd/5435505 Usage: (define-generic (length object)) (add-method (length (vector? v)) (vector-length s)) (add-method (length (string? s)) (string-length s)) (add-method (length (list? l)) (##length l)) (length "hello") => 5 (length '(1 2 3)) => 3 (length '#(a b)) => 2