[PRL] How about Tues 200-300 for macro reading group?

Eli Barzilay eli at barzilay.org
Mon Sep 13 17:24:31 EDT 2004


On Sep 13, Matthias Felleisen wrote:
> I got pretty sick staring at Perl, so I rewrote the program in Pretty 
> Big. It's 2 lines longer, argh. Anyone who knows more about our 
> libraries? -- Matthias

FWIW (not much anyway), the output is:

day  |8---|9---|10--|11--|12--|13--|14--|15--|16--|17--|18--|19--|20--|21--
mon: |....|....|....|....|XXXX|XXXX|XXX.|....|....|....|....|....|....|....
tue: |XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX
wed: |....|....|....|...X|XXXX|XXXX|XXX.|....|....|....|....|....|....|....
thu: |....|XXXX|XXXX|....|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|....
fri: |XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXX.


==============================================================================
#!/bin/sh
#|
exec swindle -r "$0" "$@"
|#

(define start-hour 0800)
(define end-hour   2200)
(define delta 15)
(define days '(mon tue wed thu fri))

(define constraints
  '(;; mitch
    (mon 1200 1330)
    (thu 0900 1100)
    (thu 1200 1330)
    (thu 1330 1445)
    (fri 0800 2145)
    ;; will
    (mon 1330 1445)
    (tue 1600 2345)
    (wed 1145 1445)
    (thu 1445 1800)
    (thu 1800 2100)
    (fri 0800 2145)
    ;; sam
    (tue 1100 1715)
    (thu 1230 1330)
    (fri 1300 1500)
    ;; jeff
    (tue 0800 1130)
    ;; pl
    (wed 1145 1330)
    ;; carl et al
    (tue 1145 1705)
    ))

(define (add-minutes time minutes)
  (let ([mins (+ minutes (modulo time 100))])
    (+ (* 100 (+ (quotient time 100) (floor (/ mins 60)))) (modulo mins 60))))
(define (+delta time) (add-minutes time delta))
(define (-delta time) (add-minutes time (- delta)))
(define (+4delta time) (add-minutes time (* 4 delta)))
(define ((range->pred lo hi) n) (< (-delta lo) n hi))
(define (pad str w) (add str (substring (make-string w #\-) (len str))))
(echo :s- "day  " :\{ "|" (list-of (pad (as <string> (quotient hour 100)) 4)
                            [hour <- start-hour +4delta ..< end-hour]) :\})
(loop-for [day <- days]
  (let ([ranges (list-of (apply range->pred (cdr x))
                  [x <- constraints] (eq? day (car x)))])
    (echo :s- day": "
          :\{ (list-of (add (if (zero? (modulo hour 100)) "|" "")
                            (if (some (lambda (r) (r hour)) ranges) "X" "."))
                [hour <- start-hour +delta ..< end-hour]) :\})))

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



More information about the PRL mailing list