[racket] another mini-tutorial: a racket slice: munging IRC logs

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Aug 11 10:12:28 EDT 2011

On Thu, Aug 11, 2011 at 4:42 AM, Marijn <hkBst at gentoo.org> wrote:
>
> I like how you show one way of converting a match to an object, and then
> show a better way. What I did not like very much is how the first way is
> really verbose and made me question whether to read on, and in
> retrospect the way using match isn't much less verbose. Wouldn't a
> simple (apply on-action (rest a-match)) work?

Fortunately, `match' provides some features that make this much nicer.
 Here's a new version (untested):

(define (parse-irc a-line)
  (match a-line
    [(regexp action-regexp
	     (list _ hour minute type msg))
     (action hour minute type msg)]
    [(regexp chat-regexp
	     (list _ hour minute who msg))
     (chat hour minute who msg)]))

Oh, and I love the original essay, Danny!
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.