[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple values for R4RS.

Let me take a stab at "quotient-and-maybe-remainder":

    (define quotient-and-maybe-remainder
       (lambda (n1 n2)
             (lambda (k)
                (if (accepts? k 2)
                    (let ([q (quotient n1 n2)])
                       (let ([r (- n1 (* q n2))])
                          (k q r)))
                    (k (quotient n1 n2)))))))
Unless I'm missing something and there is a different way to do this, I
guess I'm not too excited about "accepts?".

The predicate "accepts?" seems a little like the (rejected) predicate
"continuation?".  A procedure may not complain "up front" about a given
number of arguments, but may complain at some later time.  Or it may
accept any number of arguments, but ignore all but the first few.  I
don't see how "accepts?" can be generally useful if it breaks down in
these cases.

   (define kons
      (lambda l
         (apply cons l)))

   (accepts? cons 3) => #f
   (accepts? kons 3) => #t