[plt-dev] Racket web page

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue May 25 15:00:44 EDT 2010

On Thu, May 20, 2010 at 4:31 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> We'd like to have more 7-line programs for the middle slideshow, so
> please contribute.

Command line tool to simulate rolling M dice with N sides each, for
each input of the form "MdN":

#lang racket
(for ([s (current-command-line-arguments)])
  (match (regexp-match #px"(\\d+)d(\\d+)" s)
    [(list _ (app string->number m)
             (app string->number n))
     (for ([i (in-range m)])
       (printf "~a\n" (+ 1 (random n))))]))


[galstaff at light] roll 3d4 > darkness

Posted on the dev mailing list.