title: Writing a function that takes a function as an argument in Racket
body: <p>This is a hw assignment that requires me to write a scheme function that takes a function(with two params) and a list as parameters, then returns a list where each consecutive pair of the elements of the list is replaced by the value of the function applied to these two elements. </p>
  
  <p>For example - If the list has an odd number of elements, the last element is ignored. For example, (apply-to-pairs (lambda (x y) (+ x y)) '(3 9 5 8 2 4 7)) should return (12 13 6). </p>
  
  <p>so far what I have got is:</p>
  
  <pre><code>(define (fn-name fn l)
    (if (null? (cdr l))null
        (cons 
          (fn((car l)(car (cdr l)))
           (fn-name fn (cdr l))))))
  </code></pre>
  
  <p>However, im getting this error in Racket(DrRacket):</p>
  
  <pre><code>application: not a procedure;
   expected a procedure that can be applied to arguments
    given: 3
    arguments...:
     9
  </code></pre>
  
  <p>... and it highlights <code>fn((car lst)(car (cdr lst)))</code>. I'm trying to find out how to handle the function parameter. Thanks for the help!</p>