<div>Very nice. Thank you.</div>
<div>-pp</div>
<div> </div>
<div><br> </div>
<div><span class="gmail_quote">On 1/23/06, <b class="gmail_sendername">Robby Findler</b> <<a href="mailto:robby@cs.uchicago.edu">robby@cs.uchicago.edu</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">You have to use the more complex combinators to express that. Here's<br>how ->r can be used to express map's contract:
<br><br>(module map-c mzscheme<br>(require (lib "contract.ss"))<br><br>(define map-c map)<br><br>(provide/contract<br> [map-c<br> (->r ([func<br> (and/c<br> procedure?<br> (let ([arity-matches-lists
<br> (ë (f)<br> (procedure-arity-includes? f (+ 1 (length rest-args))))])<br> arity-matches-lists))]<br> [lst-one (listof any/c)])<br> rest-args<br> (and/c (listof (listof any/c))
<br> (let ([same-length-lists (ë (x) (apply equal? (length lst-one) (map length x)))])<br> same-length-lists))<br> (listof any/c))]))<br><br>(require map-c)<br><br>(define (print-msg exn)
<br>(display (exn-message exn))<br>(newline))<br><br>(map-c (lambda (x y) x) (list 1 2 3) (list 4 5 6))<br>(with-handlers ([values print-msg])<br>(map-c (lambda (x) x) (list 1 2 3) (list 4 5 6)))<br>(with-handlers ([values print-msg])
<br>(map-c (lambda (x y) x) (list 1 2 3) (list 4 5 6 7)))<br><br>At Mon, 23 Jan 2006 19:49:34 +0000, pedro pinto wrote:<br>> Hi there,<br>><br>> I just started fumbling around with contracts and I was trying to write a
<br>> contract for a function similar to map:<br>><br>> map proc clist1 clist2 ... -> list<br>><br>> Is there a way to say that proc is a procedure whose arity should match the<br>> number of clist arguments?
<br>><br>> TIA,<br>> -pp<br>> _________________________________________________<br>> For list-related administrative tasks:<br>> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme
</a><br></blockquote></div><br>