Computer Science Canada

Scheme help

Author:  chrisbrown [ Sat Jan 16, 2010 8:20 pm ]
Post subject:  Scheme help

I've run into an interesting dilema:

I have a function that consumes a natural number n and produces a list of length n, where each item is a result of a (read) call:
Scheme:
(define (make-list n)
  (cond [(zero? n) empty]
        [else (cons (read) (make-list (sub1 n)))]))


I also have this function which consumes a function, determines its arity (the number of parameters it consumes), and returns a (make-list) of that length
Scheme:
(define (param-list f)
  (define n (procedure-arity f))
  (make-list n))



My question is this: is there some way for test-fcn to return the result of f with the values in plist as its arguments? (Assuming f takes a constant number of arguments)
Scheme:
(define (test-fcn f)
  (define plist (param-list f)))
;;  ???)

;; ??? should be the result of (f (first plist) (second plist) ... (last plist)) where plist is of arbitrary length

;; Edit: ??? = (apply f plist)



Nevermind, found the solution.


: