Anonymous user
Simple database: Difference between revisions
m
→{{header|Common Lisp}}: improve search, add match by words, search tags
(→{{header|Common Lisp}}: add search function, search title and tags, list all tags) |
m (→{{header|Common Lisp}}: improve search, add match by words, search tags) |
||
Line 431:
(defun match-title (term episode)
(when (
(defun fuzzy-title (term episode)
(when (set-difference
(mapcar #'(lambda (word)
(search word (episode-title episode) :test 'string-equal))
term)
'(NIL))
episode))
(defun match-tags (term episode)
(when (intersection (mapcar #'intern term) (episode-tags episode))
episode))
(defun search-all (term database)
Line 440 ⟶ 452:
(mapcar #'(lambda (episode)
(cond ((match-title term episode)
(push episode exact-results
((fuzzy-title term episode)
(push episode fuzzy-results))
((match-tags term episode)
(push episode tag-results))))
(get-all database))
(append (sort exact-results #'compare-by-date)
(sort tag-results #'compare-by-date)
(sort fuzzy-results #'compare-by-date))))
(defun watch-search (term)
(format t "~{~& ~a~%~}"
(defun list-all-tags (database)
|