title: Why is my list reverse function working on its own, but not inside of another function?
body: <p>I am trying to call a reverse function I wrote (that works when called alone) inside another function, but it outputs incorrect results.</p>
  
  <p>I'm writing a program to take the derivative, with respect to x, of a bivariate polynomial. I have a main function called <strong>poly_derx</strong> which will call my two helper functions <strong>reverse_list</strong> and <strong>mult_by_index</strong>.</p>
  
  <pre><code>(define (mult_by_index list_1)
    (if (null? list_1)
        list_1
        (map * list_1 (range (length list_1)))))
  
  (define (reverse_list list_1)
    (if (null? list_1)
        list_1
        (append(reverse (cdr list_1)) (list (car list_1)))))
  
  (define (poly_derx list_1)
    (if (null? list_1)
        list_1
        (reverse_list(cons (mult_by_index (car list_1)) (poly_derx (cdr list_1))))))
  
  (poly_derx `( (1) (1 2 3) () (3)))
  </code></pre>
  
  <p>Again, my 3 functions work fine until I add the <strong>reverse_list</strong> in <strong>poly_derx</strong>. Also, I know there is a built in reverse but I face the same issue.</p>
  
  <p>At this point, the only thing I know to do  is try calling reverse at different points in the function but nothing I know of works.</p>