[plt-scheme] Contract with keyword help

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Dec 23 20:35:44 EST 2009

I don't think that you can do better using the builtin combinatiors,
no (you may be able to do better by making your own contract

I may be missing something, but what else might you like to say in the
contract? That the hash maps the keywords that were in the argument
list (via a dependent contact)?


2009/12/23 Todd O'Bryan <toddobryan at gmail.com>:
> (define make-hash-with-vals
>  (make-keyword-procedure
>   (λ (kws kw-args . rest)
>     (let ([h (make-hash)])
>       (for ([kw kws] [val kw-args])
>         (hash-set! h kw val))
>       h))))
> Can I write a more informative contract for this function than
> (unconstrained-domain-> (hash/c keyword? any))?
>> (make-hash-with-vals #:one 1 #:two 2)
> #hash((#:one . 1) (#:two . 2))
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.