make-timeline   scheme

Defined in:


; accepts an associative list as the timeline argument
; returns an event at a given time from the alist
; if a new pair is passed then add that pair to the end of timeline
(define make-timeline
   (lambda (timeline)
      (if (null? timeline)
    (lambda (time)
       (if (pair? time)
     (set! timeline (append timeline (list time)))
     (let loop ((lst (reverse timeline)))
        (cond ((null? lst) '())
        ((>= time (caar lst))
         (cdar lst))
        (else (loop (cdr lst))))))))))

Back to Index