simple method help please?

Discussion of Common Lisp

simple method help please?

Postby paulio » Tue Dec 08, 2009 2:39 am

Hi guys,

I have this database of houses, Im trying to make a method so when the user types the housename in like (house1) then the list of everything within it will return. can anyone help please?
Heres the lisp code:

Code: Select all
(setf *house-db
      '(
   ;; first house
   ((name house1)    
    (type terrace)
    (rooms ((kitchen ((dimensions (20 12))(appliances (cooker))))
       (bathroom ((dimensions (10 14))(features (bath toilet))))
       (bedrooms ((bedroom1 ((dimensions (15 21))(features (double-bed ))))))))
    (garden (pond lawn shed)))
   ;;
   ((name house2)    
    (type terrace)
    (rooms ((kitchen ((dimensions (2 1))(appliances (dishwasher))))
       (bathroom ((dimensions (11 12))(features (toilet))))
       (bedrooms ((bedroom1 ((dimensions (8 20))(features (chandelier))))
             (bedroom2 ((dimensions (8 20))(features (chandelier))))
             (bedroom3 ((dimensions (8 20))(features (chandelier))))
             (bedroom4 ((dimensions (15 21))(features (double-bed washbasin))))))))
    (garden (shed)))
))


i want to return this when the user types in 'house1' for example:
Code: Select all
((name house1)    
    (type terrace)
    (rooms ((kitchen ((dimensions (20 12))(appliances (cooker))))
       (bathroom ((dimensions (10 14))(features (bath toilet))))
       (bedrooms ((bedroom1 ((dimensions (15 21))(features (double-bed ))))))))
    (garden (pond lawn shed)))


so iv started with the method heading

(defun get-house (housename)

but iv tried lots of different stuff but cant get it to work, please help!
paulio
 

Re: simple method help please?

Postby nuntius » Sun Dec 13, 2009 12:17 am

User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 1 guest