[plt-scheme] eliminate expensive toys: please critique the solution

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Wed Feb 11 06:43:51 EST 2004

A few possible solutions:

Internal Define:

 (define (e-e thresh tl)
   (define (e-e-internal ...)
      ... )
   (e-e-internal empty thresh tl))

Letrec:

  (define (e-e thresh t1)
    (letrec ((e-e-internal ...))
       (e-e-internal ...))

Simple recursion:

  (define (e-e thresh t1)
     (cond [(empty? t1) (list)]
           [(> (first t1) thresh)
             (e-e thresh t1)]
           [else (cons (first t1)
                       (e-e thresh (rest t1)))]))

BTW, you could use better variable names.  t1 is
hardly descriptive.

HTH,
Noel

=====
Email: noelwelsh <at> yahoo <dot> com
Jabber: noelw <at> jabber <dot> org

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Posted on the users mailing list.