Pattern matching question for Swindle
- From: Jeff Heard <heard@xxxxxxxxxx>
- Date: Sun, 06 Aug 2006 23:41:40 GMT
Hi,
I'm using PLT scheme with Swindle and SSAX (latest version of everything) to write a simple program which locates and plays songs using the iTunes Music Library XML file. Why don't I use iTunes? Because I'm doing this on Linux. It's all fairly straightforward until I get down to handling the XML file itself.
The library file is huge -- in excess of 140MB on disk, and storing the entire XML file in memory as SXML is undesirable, as I want to be able to run more than one program in memory on my tiny little server. For the same reason, I'd also like to do only one pass on the data.
To get to the point, my approach has been to, at the element-finish stage, to match against a partial SXML and rewrite it. I will have something very like this structure in the "seed" parameter in the FINISH-LEVEL handler:
'(dict
(key "38")
(dict
(key "Track ID")
(integer "38")
(key "Track Number")
(integer 1)
(key "Name")
(string "Rhapsody in Blue")
(key "Artist")
(string "Andre Previn")
(key "Composer")
(string "George Gershwin")
(key "Genre")
(string "Classical")))
I may have more or fewer "key" elements, but there will be only one (or integer string data float true false) elements after each key. What I've wanted to do is this:
(let/match
('dict
('key *)
('dict items := ...))
seed
(let ((track (make-track)))
; create the track from items and put it on the end of the seed )
To create a structure that looks like:
(dict
<struct:track>
...)
That let/match, of course, doesn't work. Can anyone tell me what I'm doing wrong? Is there a "better" pattern matcher for PLT-Scheme or a better solution to this problem I'm missing? Swindle looks like a wonderful library, but I'm at a loss sometimes on how to use it.
I guess a good answer would generalize, too. What is the best way to pattern-match on a deeply nested list?
- Jeff
.
- Follow-Ups:
- Re: Pattern matching question for Swindle
- From: noelwelsh
- Re: Pattern matching question for Swindle
- Prev by Date: Re: Is string-ref O(1) ?
- Next by Date: Re: Is string-ref O(1) ?
- Previous by thread: DNS, IS THERE A SCHEME DNS REPLACEMENT?
- Next by thread: Re: Pattern matching question for Swindle
- Index(es):
Relevant Pages
|