[plt-scheme] Re: Contract question

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Jan 23 15:23:40 EST 2006

At Mon, 23 Jan 2006 14:55:36 -0500, David Van Horn wrote:
> pedro pinto wrote:
> > Hi there,
> >  
> > I just started fumbling around with contracts and I was trying to write 
> > a contract for a function similar to map:
> >  
> > map proc clist1 clist2 ... -> list
> >  
> > Is there a way to say that proc is a procedure whose arity should match 
> > the number of clist arguments?
> 
> (->r ([proc
>           (and/c procedure?
>             (lambda (_)
>               (procedure-arity-includes? proc
>                  (length arg-lists))))])
> 
>     arg-lists (lambda (_) (ormap proper-list? arg-lists))
>     proper-list?)

I tried this one too, but it turns out that map expects at least two
arguments, so that contract doesn't match map.

:)

Robby


Posted on the users mailing list.