<HTML><BODY><div><font face="courier new, monospace">Or even simpler <br><br>(define (dup a)<br> (cond</font></div><div><font face="courier new, monospace"> [(string? a) (string-append a a)]</font></div><div><font face="courier new, monospace"> [(integer? a) (list a a)])<br><br></font></div>:-)<br><br>I think, Alejandro wanted to add clauses in different places (generic in one module, added method in another, for example).<br><br><br>Thu, 3 Apr 2014 20:11:36 +1100 от Daniel Prager <daniel.a.prager@gmail.com>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
<div id="">
<div class="js-helper js-readmsg-msg">
<style type="text/css"></style>
<div>
<base target="_self" href="https://e.mail.ru/">
<div id="style_13965167960000000572_BODY"><div dir="ltr"><div>Here's an out-of-the-box option, using Racket's <a href="http://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29" target="_blank">pattern matching</a> with the (? predicate) form:</div>
<div><br></div><div><font face="courier new, monospace">(define/match (dup a)</font></div><div><font face="courier new, monospace"> [((? string?)) (string-append a a)]</font></div><div><font face="courier new, monospace"> [((? integer?)) (list a a)])</font></div>
<div><br></div><div>Dan</div><div><div dir="ltr"></div>
</div></div>
</div>
<div>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</div>
<base target="_self" href="https://e.mail.ru/">
</div>
</div>
</div>
</blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>