[racket] procedure contract for "at least N arguments, possibly more"

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jun 9 11:24:03 EDT 2012

Neil, do you mean something like this: 

#lang racket

(define (f p1 p2)
  (define history '())
  (lambda (x)
    (define v1 (p1 x))
    (set! history (cons x history))
    (apply p2 1 2 history)))

(define g (f values (lambda (x1 x2 . h) (displayln (list* 'p2 x1 x2 h)))))

(g 'a)
(g 'b)
(g 'c)

On Jun 8, 2012, at 9:31 PM, Robby Findler wrote:

> To get a little more context: what happens if P1 returns different
> numbers of values each time it is called? How do you know which ones
> match up to which calls of P2?
> Also, perhaps not the best thing (pending the answer above), you can
> write a predicate contract that gets the procedure-arity result and do
> what you want with it. That doesn't work well if you want to actually
> put contracts on the two arguments, tho.
> Robby
> On Fri, Jun 8, 2012 at 6:13 PM, Neil Van Dyke <neil at neilvandyke.org> wrote:
>> Is there a way with the core procedure contractor combinators, to say "at
>> least 2 arguments, possibly more"?
>> So far, I have gotten "->*" to give me "2 arguments and arbitrarily more",
>> which is not what I want.
>> (Rationale for why I want "at least 2 arguments, possibly more"... I have a
>> library procedure that accepts two provided procedures, P1 and P2.  It
>> applies P1 in one context and saves the value(s) returned, then applies P2
>> in a different context with two fixed arguments plus an additional argument
>> for each value saved from applying P1.  So, I just want the contract for P2
>> to require the 2 fixed arguments, and permit additional arguments, but not
>> require P2 to accept arbitrary arguments.)
>> Neil V.
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.