Simple database: Difference between revisions

→‎{{header|Common Lisp}}: handle non-numeric month values
(→‎{{header|Common Lisp}}: add default date)
(→‎{{header|Common Lisp}}: handle non-numeric month values)
Line 58:
(cond ((endp database) nil)
(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)
Line 63 ⟶ 69:
((null a) (not (null b)))
((null b) nil)
((= (first a)cal->int (first ba)) (comparecal-date>int (rest a) (restfirst b)))
(t (<compare-date (firstrest a) (firstrest b))) ))
(t (< (cal->int (first a)) (cal->int (first b))))))
 
(defun compare-by-date (a b)
Anonymous user