[plt-dev] Racket web page

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Tue May 25 13:29:15 EDT 2010

> We'd like to have more 7-line programs for the middle slideshow, so
> please contribute.

Three programs:



;; gets the unique lines, although not guaranteeing order:
(let ([a-ht  (for/fold ([a-ht #hash()])
                                ([line (in-lines (current-input-port))])
         (hash-set a-ht line #t))])
  (for ([line (in-hash-keys a-ht)])
    (printf "~a~n" line)))



;; nl: show line numbers along the side
(for ([line (in-lines (current-input-port))]
      [no (in-naturals 1)])
  (printf "~a: ~a~n" no line))



#lang racket
;; Compute md5 checksum of the file given at the command line
(require scheme/cmdline
         file/md5)
(printf "~a~n" (md5 (command-line #:args (filename) filename)))


Posted on the dev mailing list.