Accessing the Yahoo Web Search API from MzScheme

A bit of Scheme code that I was dorking around with a long time ago and never got around to posting. This probably only works in MzScheme since it uses implementation-specific APIs to do HTTP.

Here’s an example of using it:

marc@tbird:~/projects/scheme$ mzscheme 
Welcome to MzScheme version 352, Copyright (c) 2004-2006 PLT Scheme Inc.
> (load "yahoo-web-search.scm")
> (for-each-result
        (lambda(x)                                                     
                (let ((result (result->struct x)))
                        (printf "~s~n" (result-url result))))
        "query=coroutines")
"http://en.wikipedia.org/wiki/Coroutine"
"http://msdn.microsoft.com/msdnmag/issues/03/09/CoroutinesinNET/default.aspx"
"http://www.sidhe.org/~dan/blog/archives/000178.html"
"http://lua-users.org/wiki/CoroutinesTutorial"
"http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/300019"
"http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html"
"http://www.python.org/dev/peps/pep-0342/"
"http://www.softpanorama.org/Scripting/pipes.shtml"
"http://c2.com/cgi-bin/wiki?CoRoutine"
"http://cs.hubfs.net/forums/ShowThread.aspx?PostID=676"
(# # # # # # # # # #)

I’m no Scheme expert so this code is probably not particularly smart or readable, but maybe it will inspire somebody…