球拍:将其余参数映射到另一个过程

Racket: Map rest arguments to another procedure

我正在尝试获取剩余参数列表并将它们映射到 Racket 中 plot 过程的参数列表,但由于某种原因我一直运气不佳。

(define (graph fn/1
               #:grid? [grid? true] 
               #:min [min -20] 
               #:max [max 20]
               . fns)
   (define plot-input 
           (list (axes)
                 (if grid? (tick-grid) empty)
                 (function identity #:style 'dot #:width 1.5 #:color 'gray)
                 (function fn/1)
                 ;; would like (function f) for each f in fns iff fns exists
   ))
   (plot plot-input
         #:x-min min
         #:x-max max
         #:y-min min
         #:y-max max))

只需使用map:

   (define plot-input 
           (list* (axes)
                  (if grid? (tick-grid) empty)
                  (function identity #:style 'dot #:width 1.5 #:color 'gray)
                  (function fn/1)
                  ;; would like (function f) for each f in fns iff fns exists
                  (map function fns)
   ))

使用list*拼接map产生的结果列表,而不是原来的list.