


;; Simple Library Management System
;; Global variable to store books
(defvar *library* nil)
;; Function to add a book
(defun add-book (title author)
(push (list title author 'available) *library*)
(format t "~%Added: ~A by ~A" title author))
;; Function to display all books
(defun show-books ()
(format t "~%Library Contents:")
(dolist (book *library*)
(format t "~%Title: ~A, Author: ~A, Status: ~A"
(first book)
(second book)
(third book))))
;; Function to checkout a book
(defun checkout (title)
(let ((book (find title *library* :key #'first :test #'equal)))
(if book
(progn
(setf (third book) 'checked-out)
(format t "~%Checked out: ~A" title))
(format t "~%Book not found: ~A" title))))
;; Test the system
(defun test-library ()
(format t "~%=== Testing Library System ===")
;; Add some books
(add-book "The God of Small Things" "Arundhati Roy")
(add-book "Midnight's Children" "Salman Rushdie")
;; Show all books
(show-books)
;; Checkout a book
(checkout "The Hobbit")
(checkout "Midnight's Children")
;; Show updated library
(show-books))
;; Run the test
(test-library)
Output: