Generalize period lookups.
This commit is contained in:
parent
51b3b6f5b7
commit
e9745bc64a
2 changed files with 17 additions and 17 deletions
|
@ -51,13 +51,10 @@
|
|||
members-base
|
||||
period)
|
||||
|
||||
;; Specifications of fees, regular and student must be in all
|
||||
(define member-fees-lookup-source
|
||||
'(((2010 1) #f 500 250)))
|
||||
|
||||
;; Convert into lookups - a list of (list period regular student)
|
||||
(define member-fees-lookup-table
|
||||
(make-period-lookup-table member-fees-lookup-source))
|
||||
(make-period-lookup-table
|
||||
'(((2010 1) 500 250))))
|
||||
|
||||
;; Returns a matching list of (list regular student)
|
||||
(define (lookup-member-fees)
|
||||
|
|
27
period.scm
27
period.scm
|
@ -175,18 +175,21 @@
|
|||
|
||||
;; Creates lookup table from definition source
|
||||
(define (make-period-lookup-table source)
|
||||
(map
|
||||
(lambda (src)
|
||||
(let* ((since0 (car src))
|
||||
(since (apply make-month since0))
|
||||
(before0 (cadr src))
|
||||
(before (if before0
|
||||
(apply make-month before0)
|
||||
#f))
|
||||
(definitions (cddr src)))
|
||||
(cons (make-period since before)
|
||||
definitions)))
|
||||
source))
|
||||
(let loop ((lst source)
|
||||
(res '())
|
||||
(prev #f))
|
||||
(if (null? lst)
|
||||
(reverse
|
||||
(cons (cons (make-period (car prev) #f)
|
||||
(cdr prev))
|
||||
res))
|
||||
(loop (cdr lst)
|
||||
(if prev
|
||||
(cons (cons (make-period (car prev) (caar lst))
|
||||
(cdr prev))
|
||||
res)
|
||||
res)
|
||||
(car lst)))))
|
||||
|
||||
;; Looks up current month and returns associated definitions
|
||||
(define (lookup-by-period table)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue