Or even simpler 

(define (dup a)
  (cond
    [(string? a) (string-append a a)]
    [(integer? a) (list a a)])

:-)

I think, Alejandro wanted to add clauses in different places (generic in one 
module, added method in another, for example).


Thu, 3 Apr 2014 20:11:36 +1100 от Daniel Prager <daniel.a.pra...@gmail.com>:
>Here's an out-of-the-box option, using Racket's  pattern matching  with the (? 
>predicate) form:
>
>(define/match (dup a)
>  [((? string?)) (string-append a a)]
>  [((? integer?)) (list a a)])
>
>Dan
>____________________
>  Racket Users list:
>   http://lists.racket-lang.org/users
>


-- 
Roman Klochkov
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to