[plt-scheme] help writing idiomatic plt scheme

From: John Clements (clements at brinckerhoff.org)
Date: Sun Jun 15 14:51:47 EDT 2008

On Jun 14, 2008, at 7:39 PM, Martin DeMello wrote:

> I've pasted a program fragment in at http://pastebin.com/f152f0ea4 - I
> would like some help improving it in terms of making it more concise
> and idiomatic, since I have the feeling I'm doing too much work for a
> fundamentally simple problem.

Here's how I'd write it[*]:

(define (read-bundles lines)
   (match lines
     [(list (? hash-line? h) ... (? eq-line? e) ... (? hash-line?  
h) ... (? eq-line? e) ... super-...)
      (list (combine-hash-lines (h ...)) (combine-eq-lines (e ...))  
super-...)]))


The implementation of the "super-..." pattern is left as an exercise  
to the master macrologist.

Also, I see that you have to double this in case the file starts with  
"=" lines instead, and I'm not quite sure what to do about that.

John

[*] if I could.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20080615/3909a494/attachment.p7s>

Posted on the users mailing list.