[plt-scheme] Some contract advice

From: Grant Rettke (grettke at acm.org)
Date: Sun Mar 22 12:01:45 EDT 2009

Is the best way to write a contract for a function that takes a list
of natural numbers of length >= 2 and outputs a list of natural
numbers that is the same length as the input?

     ([argument (and/c (flat-named-contract
                        (λ (ls) (>= (length ls) 2)))
                       (listof natural-number/c))])
     (result (and/c (flat-named-contract
                     (λ (ls) (= (length ls) (length argument))))
                    (listof natural-number/c))))

Posted on the users mailing list.