Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (28 sloc) 0.933 kB
(use srfi-1 srfi-69)
; filters result of ad based on specifics given as strings
; ex: (ad-filter (ad "TnT" 'book) '("TnT" 'book)) equals (ad "TnT" 'book)
(define (ad-filter data-l params)
(if (> (length params) 0)
(if (string? (first params))
(ad-filter (second (first (filter (lambda (e) (string=? (first params) (first e))) data-l))) (cdr params))
data-l)
data-l))
(define *mem-ht* (make-hash-table))
(define (ad . rest)
(if (hash-table-ref/default *mem-ht* rest #f)
(hash-table-ref *mem-ht* rest)
(let ((r (letrec ((ad-internal
(lambda (ol params)
(if (= (length params) 1)
(map (lambda (l)
(if (list? l)
(first l)
l))
(second ol))
(map (lambda (l)
`(,(first l)
,(ad-internal l (cdr params))))
(second ol))))))
(ad-filter (ad-internal (section-data) rest) rest))))
(hash-table-set! *mem-ht* rest r)
r)))
Jump to Line
Something went wrong with that request. Please try again.