[PRL] How about Tues 200-300 for macro reading group?
Eli Barzilay
eli at barzilay.org
Mon Sep 13 17:38:40 EDT 2004
For Matthias --
New output:
day |8---|9---|10--|11--|12--|13--|14--|15--|16--|17--|18--|19--|20--|21--
mon: |....|....|....|....|1111|1111|111.|....|....|....|....|....|....|....
tue: |1111|1111|1111|2212|2222|2222|2222|2222|3333|3111|1111|1111|1111|1111
wed: |....|....|....|...2|2222|2211|111.|....|....|....|....|....|....|....
thu: |....|1111|1111|....|1122|2211|1111|1111|1111|1111|1111|1111|1111|....
fri: |2222|2222|2222|2222|2222|3333|3333|2222|2222|2222|2222|2222|2222|222.
New code, minor change:
================================================================================
#!/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)) "|" "")
(let ([c (count-of [r <- ranges] (r hour))])
(if (zero? c) "." (as <string> c))))
[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