Simple database: Difference between revisions
Content added Content deleted
(→{{header|Common Lisp}}: add default date) |
(→{{header|Common Lisp}}: handle non-numeric month values) |
||
Line 58: | Line 58: | ||
(cond ((endp database) nil) |
(cond ((endp database) nil) |
||
(T (cons (cadr (assoc 'episodes (cdar database))) (get-latest (cdr database)))))) |
(T (cons (cadr (assoc 'episodes (cdar database))) (get-latest (cdr database)))))) |
||
(defun cal->int (cal) |
|||
(cond ((integerp cal) cal) |
|||
(T (get-value cal '(('jan . 1) ('feb . 2) ('mar . 3) ('apr . 4) |
|||
('may . 5) ('jun . 6) ('jul . 7) ('aug . 8) |
|||
('sep . 9) ('oct . 10) ('nov . 11) ('dec . 12)))))) |
|||
(defun compare-date (a b) |
(defun compare-date (a b) |
||
Line 63: | Line 69: | ||
((null a) (not (null b))) |
((null a) (not (null b))) |
||
((null b) nil) |
((null b) nil) |
||
((= ( |
((= (cal->int (first a)) (cal->int (first b))) |
||
(compare-date (rest a) (rest b))) |
|||
(t (< (cal->int (first a)) (cal->int (first b)))))) |
|||
(defun compare-by-date (a b) |
(defun compare-by-date (a b) |