[plt-scheme] Re: How to learn about typical applications of the match library?

From: Pedro Pinto (pedropinto at quarksoftllc.com)
Date: Wed Jul 11 12:48:49 EDT 2007

Here is a quick example. I have a cron job that logs the the number of
lines of a code in a code base of mine. Each line in the log looks
like this:

((date 03 07 07) (time 16 00 01) (lang1 loc1) (lang2 loc2) ...)

where lang1, lang2 are different programming languages and loc1, loc2
are their respective line counts.

At some point I need to do a little bit of analysis of this
log. Though the above is straightforward to parse, the match
library made it trivial:

       (match log-line ( (('date day month year)
                          ('time hour min sec)
                          (lang-list locs-list) ...)
	              (begin
                          (printf "day:~a month:~a year:~a~n"
                                  day month year
                          (for-each (lambda (lang loc)
				     (printf "lang:~a loc:~a~n" lang loc))
                                    lang-list loc-list)))))


-pp



	





Posted on the users mailing list.