title: Not a Procedure, Really?
body: <p>I been trying to figure this out for like 2 hours now! please Consider the following code:</p>
  
  <pre><code>(define (PowListF list) 
    (PowListFHelp list (- (length list) 1)))
  
  (define (FuncPow f n) 
    (if (= 0 n)
        f
        (lambda (x)
          (FuncPow (f (- n 1)) x))))
  
  (define (PowListFHelp list n) 
    (if (= n 0)
        (list (list-ref list 0))
        (cons (FuncPow (list-ref list n) n)
              (PowListFHelp list (- n 1)))))
  </code></pre>
  
  <p>The rocket Scheme compilers give me error:
  application: not a procedure;
   expected a procedure that can be applied to arguments
    given: (# #)
    arguments...:
     #</p>
  
  <p>and it points to the (cons part...</p>
  
  <p>and The following code, that uses the same if structure, does work:</p>
  
  <pre><code>(define (polyCheb n)
    (reverse (polyChebHelp n)))
  
  (define (polyChebHelp n)
    (if (= n 0)
        (list (polyChebFunc n))
        (cons (polyChebFunc n)
              (polyChebHelp (- n 1)))))
  
  (define (polyChebFunc n)
    (if (= n 0)
        (lambda (x) 1)
        (if (= n 1) 
            (lambda (x) x)     
            (lambda (x)
              (- (* (* 2 x)
                    ((polyChebFunc(- n 1)) x))
                 ((polyChebFunc(- n 2)) x))))))
  </code></pre>
  
  <p>EDIT: PowListF is being given list of functions as parameter, returns the same list s.t every function is composed with itself (its index + 1) times...</p>
  
  <p>usage:
  ((list-ref (PowListF (list (lambda (x) x) (lambda (x) (expt x 2)))) 1) 2)
  value should be 2^2^2=2^4=16</p>
  
  <p>EDIT 2:</p>
  
  <p>This was the solution : </p>
  
  <pre><code>(define (FuncPow f n) 
    (if (= 0 n)
        f
        (lambda (x) (f ((FuncPow f (- n 1)) x)))))
  </code></pre>