[plt-dev] Racket web page

From: Guillaume Marceau (gmarceau at gmail.com)
Date: Tue May 25 16:43:03 EDT 2010

;; Indents a multi-line string by n spaces
#lang racket
(define (indent str n)
  (define blanks (make-string n #\space))
   (for/list ([line (regexp-split #"\n" str)])
     (format "~a~a" blanks line))

;; Another attempt at shrinking the google query example. Is this
still too wide?
#lang racket
(require net/url net/uri-codec)
(define (google-query q)
  (let ([g "http://www.google.com/search?q="]
        [u (string-append g (uri-encode q))]
        [rx #rx"(?<=<h3 class=\"r\">).*?(?=</h3>)"])
    (regexp-match* rx (get-pure-port (string->url u)))))

Posted on the dev mailing list.