<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>You can use or/c to do this, as long as you guard them like this so that no more than one contract matches at a time:</div><div><div><font face="Courier New">(or/c</font></div><div><font face="Courier New"> (and/c (procedure-has-arity/c 2) (-> input-port? any/c any))</font></div><div><font face="Courier New"> (and/c (procedure-has-arity/c 3) (-> input-port? any/c any/c any))</font></div><div><font face="Courier New"> (and/c (procedure-has-arity/c 4) (-> input-port? any/c any/c any/c any))</font></div><div><font face="Courier New"> (->* (input-port? any/c) #:rest list? any)</font></div><div><font face="Courier New"> )</font></div></div><div><br></div><div>Or, you could use if/c from unstable/contract, or define a cond/c macro like this:</div><div><div><font face="Courier New">(require unstable/contract)</font></div><div><font face="Courier New">(define-syntax cond/c</font></div><div><font face="Courier New"> (syntax-rules (else)</font></div><div><font face="Courier New"> [(cond/c) none/c]</font></div><div><font face="Courier New"> [(cond/c [else else-c])</font></div><div><font face="Courier New"> else-c]</font></div><div><font face="Courier New"> [(cond/c [pred then-c] clause ...)</font></div><div><font face="Courier New"> (if/c pred</font></div><div><font face="Courier New"> then-c</font></div><div><font face="Courier New"> (cond/c clause ...))]))</font></div></div><div><font face="Courier New"><br></font></div><div><div><font face="Courier New">(cond/c [(procedure-has-arity/c 2) (-> input-port? any/c any)]</font></div><div><font face="Courier New"> [(procedure-has-arity/c 3) (-> input-port? any/c any/c any)]</font></div><div><font face="Courier New"> [(procedure-has-arity/c 4) (-> input-port? any/c any/c any/c any)]</font></div><div><font face="Courier New"> [else (->* (input-port? any/c) #:rest list? any)])</font></div></div><div><br></div><div>By the way it has to be procedure-has-arity/c, not procedure-includes-arity/c:</div><div><div><font face="Courier New">(define (procedure-has-arity/c arity)</font></div><div><font face="Courier New"> (define normalized-arity (normalize-arity arity))</font></div><div><font face="Courier New"> (flat-named-contract</font></div><div><font face="Courier New"> `(procedure-has-arity/c ,normalized-arity)</font></div><div><font face="Courier New"> (λ (f)</font></div><div><font face="Courier New"> (and (procedure? f)</font></div><div><font face="Courier New"> (arity=? (procedure-arity f) normalized-arity)))))</font></div></div><br><div><div>On Jun 29, 2014, at 8:00 AM, Roman Klochkov <<a href="mailto:kalimehtar@mail.ru">kalimehtar@mail.ru</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div><p>How to make a contract, that accepts <br>(-> input-port? any/c any)<br>(-> input-port? any/c any/c any)<br>(-> input-port? any/c any/c any/c any)<br>...<br>and<br>(->* (input-port? any/c) #:rest list? any)</p><p><br>So theare should be at least two args and first arg should be input-port.<br><br>-- <br>Roman Klochkov</p></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>