wisemonkeys logo
FeedNotificationProfile
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

LISP - Library Management System

profile
Fatima Shaikh
Jul 16, 2025
4 Likes
7 Discussions
0 Reads

;; 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:



Comments ()


Sign in

Read Next

What is Anxiety? How to manage Anxiety?

Blog banner

ART AND CULTURE OF VRINDAVAN

Blog banner

The Right way of cooking

Blog banner

Fudgy Tahini Date Chocolate Bars

Blog banner

Tomato Butter Sauce with Bucatini

Blog banner

Super Garlicky Tomato Soup with Smashed White Beans

Blog banner

Fitness

Blog banner

Guidelines for a Low sodium Diet.

Blog banner