[PRL] How about Tues 200-300 for macro reading group?
Matthias Felleisen
matthias at ccs.neu.edu
Mon Sep 13 15:52:14 EDT 2004
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
; day -> constraints
; a constraints is a list of (start,stop) times
(define %constraints
#hash(
; mitch will
(mon . [(1200 1330) (1330 1445)])
; carl et al. will sam jeff
(tue . [(1145 1705) (1600 2345) (1100 0515) (0800 1130)])
; pl will
(wed . [(1145 1330) (1145 1445)])
; mitch mitch mitch will will
sam
(thu . [(0900 1100) (1200 1330) (1330 1445) (1445 1800) (1800 2100)
(1230 1330)])
; mitch will sam
(fri . [(0800 2145) (0800 2145) (1300 1500)])
))
(define start-hour 8)
(define end-hour 22)
(define xxx
(apply
string-append
"Day"
(build-list
(- end-hour start-hour)
(lambda (i) (let ([i (+ start-hour i)]) (format (if (< i 10) "
0~a00" " ~a00") i))))))
(define (convert-to-1 p)
(let ([start (car p)][end (cadr p)])
(build-vector
(* (- end-hour start-hour) 5)
(lambda (i)
(let ([time (+ (* 100 (+ start-hour (quotient i 5))) (* 15
(remainder i 5)))])
(cond
[(= (remainder i 5) 0) 0]
[(and (< start time) (<= time end)) 1]
[else 0]))))))
(define (match l)
(build-string (* (- end-hour start-hour) 5)
(lambda (i)
(let ([n (apply + (map (lambda (s) (vector-ref s i))
l))])
(if (= n 0) #\space (string-ref (number->string n)
0))))))
More information about the PRL
mailing list