Hi all, In trying to teach myself Lisp and programming in general, I set out to do a little project that would be challenging enough and yet doable with the little Lisp knowledge I have gathered so far, but I am stuck somewhere. I don't know what the best approach is. I have defined some hash tables which hold my friends' contact information, like this: (defparameter mt (make-hash-table))
(setf (gethash 'name mt) "Name" (gethash 'physical-address mt) "Physical address" (gethash 'postal-address mt) "Postal address" (gethash 'specializes-in mt) "Job" (gethash 'home mt) "Home telephone number" (gethash 'work mt) "Work telephone number" (gethash 'mobile mt) "Mobile number") Then I have defined the following two functions: (defun disp-info (k v) (format t "~a:~20t~a~%" k v)) (defun show-me (hash-table-name) (maphash #'disp-info hash-table-name)) So, I am able to say: (show-me mt) to get nicely formated information about my friend M.T. This is OK. But suppose I wanted to have hash tables that, for instance, contained information about all the computer shops in my town; their contact info, computer peripherals they stock, and the prices so that I would say (lookfor mouse) ;specifying only the value and get any number of dealers that exist in my hash table database with all the relevant info in this form: NAME: Targus mouse PRICE: $3.00 IN STOCK: 1 available. WHERE: CompuTech PHYSICAL ADDRESS: Keystone Building, 24 Dry Street, Monstrous City. TEL: 06-234-5678. EMAIL: [email protected] WEBSITE: www.computech-world.com <http://www.computech-world.com/> NAME: Computer mice PRICE: from $10.00 IN STOCK: bulk available. WHERE: Makina Machines PHYSICAL ADDRESS: Central Arcade, City Center. TEL: 26-231-5999. EMAIL: [email protected] WEBSITE: www.makina.com <http://www.makina.com/> All the information I have on hash tables does not answer some of my basic questions, like, (1) Are hash tables the right tool for this sort of information? What are some alternatives? (2) What kind of abstraction would I use to search ALL individual hash tables at once without specifying any single hash table? (3) As data structures, what are hash tables really good for? Thanks in advance for your kind assistance. Harrison.
_______________________________________________ Gardeners mailing list [email protected] http://www.lispniks.com/mailman/listinfo/gardeners
