I'm trying to write a generalization of map that supports multiple return
values:

(define (map-n n f ls . lss)
  (if (empty? ls)
      (apply values (build-list n (lambda _ '())))
      (call-with-values
       (thunk (apply f (car ls) (map car lss)))
       (lambda vs
         (call-with-values
          (thunk (apply map-n n f (cdr ls) (map cdr lss)))
          (lambda lss
            (apply
             values
             (map cons vs lss))))))))

This version works fine, but, tediously, requires I specify how many return
values.
This is annoying, since surely the context knows how many values it expects:

> (let/ec escape
    (let-values ([(a b c)
                  (let/cc k
                    (escape (procedure-arity k)))])
      'meow))
> (arity-at-least 0)

Oh, I guess not.
Well that's fine, because surely I can reflect on `f`'s result arity:

> (procedure-result-arity (lambda (x) (values 'a 'b 'c)))
> #f

Welp.

So, uh, can I haz a current-context-arity please?

-- 
William J. Bowman

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200328002810.GN31619%40williamjbowman.com.

Reply via email to