title: Tail recursion and CPS
body: <p>I have been stuck on this problem for a while. I pass in a predicate and a list to another function in scheme. If the predicate gives you true, you add it to your answer list, else you skip it.</p>
  
  <p>For example, <code>(myfilt positive? '(1 -2 3))</code> should be <code>(1 3)</code>. But I have been getting <code>(1 . 0)</code>.</p>
  
  <pre><code>(define myfilt
     (letrec ([testfilt (lambda (x poly function)
                          (if (empty? poly)
                              (function '())
                              (testfilt x (rest poly)
                                        (lambda (v)
                                          (function (if (x (car poly))
                                                        (cons (car poly) v)
                                                        0))))))]
              [identity (lambda (x) x)])
       (lambda (x poly)
         (testfilt x poly identity))))
  </code></pre>