Open In App

Structures in LISP

LISP, is a list processing, is a programming language widely used in working with data manipulation. Structures are used defines data types, that have the ability to combine with another data type to complete the given task.

Attribute used:



Example 1:




/* LISP Creating a book.lisp file to 
/* store the information of book. 
  
(defstruct book 
   title 
   author 
   book-id 
)
  
( setq book1 (make-book :title "Geek Programming"
   :author "Ayush Agarwal" 
   :book-id "101")
)
  
( setq book2 (make-book :title "Harry Potter"
   :author "J. K.Rowling" 
   :book-id "102")
(write book1)
(terpri)
(write book2)
(setq book3( copy-book book1))
(setf (book-book-id book3) 100
(terpri)
(write book3)

Output:



 

Example 2: 




/* Creating a Staff.lisp file to store
/* the information of Staff working in a company. 
  
(defstruct Staff
   employee
   salary
   Pin-code
)
  
( setq employee1 (make-Staff :employee "Rahul Raj"
   :salary "20 thousand" 
   :Pin-code "700055")
)
  
( setq employee2 (make-Staff :employee "Dhruv Rathee"
   :salary "10 thousand" 
   :Pin-code "400020")
(write employee1)
(terpri)
(write employee2)
(setq employee3( copy-Staff employee1))
(setf (Staff-Staff-id employee3) 100
(terpri)

Output:

 


Article Tags :