<div>
<div>One more question, how would I go about saying something about the return type of proc/func? From my understanding of the docs I need to write a function contract, as opposed to what I think is a flat-contract like arity-matches-lists, but I did not see a way to write one that does not also pin down the arity.
</div>
<div> </div>
<div>-pp</div>
<div><br> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div><span class="q" id="q_108f91bc8391e4ba_2">
<div><span class="gmail_quote">On 1/23/06, <b class="gmail_sendername">Robby Findler</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:robby@cs.uchicago.edu" target="_blank">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 onclick="return top.js.OpenExtLink(window,event,this)" href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">
http://list.cs.brown.edu/mailman/listinfo/plt-scheme </a><br></blockquote></div><br></span></div></blockquote></div><br>