[plt-scheme] Cute little macro

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Sep 25 17:41:39 EDT 2009

I'm teaching an algorithms class and the students did a project
implementing quicksort with different numbers of pivots. [1]

Many students wrote one function for each pivot number, but a few
wrote one function. No one wrote a macro to generate the specialized
functions... except me!

The file is attached for those interested. To test it, you need to run
it once to get a test file, but I suggest you just look at the macro
expansion in the macro stepper. There are 3 implementations of the
individual functions, then a macro that could generate each of the
others... and any number of pivots. (Try 12 for craziness.)


1. http://faculty.cs.byu.edu/~jay/courses/2009/fall/312/course/qsort3.html

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qsort3.ss
Type: application/octet-stream
Size: 7625 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20090925/572beb0b/attachment.obj>

Posted on the users mailing list.