Hi Alessio, Thanks for your prompt response. What you say is enlightening. Harriso.
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Alessio Stalla Sent: Thursday, March 19, 2009 1:18 PM To: Tending the Lisp Garden Subject: Re: [Gardeners] Hash Tables in General 2009/3/19 Harrison Maseko <[email protected]>: > 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: Hello, Since you want to store a fixed number of fields for every object, structures or classes are better suited for your task: (defstruct person name physical-address postal-address etc-etc) (defparameter mt (make-person :name "Name" :physical-address "Physical address" :etc-etc "...")) (person-name mt) ==> "Name" Regarding your "computer shops" database, you have to choose a datastructure that can represent the relations: 1. shop --sells-many--> peripherals 2. peripheral --is-sold-by-many--> shops i.e. a "many to many" relation. What datastructure to choose is partially influenced by how you want to use it. In the general case you could have a big list (or array) of shops and a big list/array of peripherals and have each shop keep a list of peripherals it sells, and each peripheral a list of shops where it is sold. Such a datastructure is hard to manage (e.g. you have to update it in multiple places to keep it consistent when you add/remove shops or peripherals). Given your specific requirements, you could instead use some simpler datastructure that e.g. privileges only one side of the many-to-many relation (e.g. making it simpler to get the list of shops that sell an item but harder to get the list of items sold by a shop). Morale: since you're learning, use your imagination, experiment, use a lot of trial-and-error, study a little theory, and ultimately choose what you feel more confident with. Then if you want post your solution here and people will surely provide you with advice, correct mistakes, etc. Alessio _______________________________________________ Gardeners mailing list [email protected] http://www.lispniks.com/mailman/listinfo/gardeners No virus found in this incoming message. Checked by AVG. Version: 8.0.169 / Virus Database: 270.11.19/2011 - Release Date: 3/19/2009 7:05 AM _______________________________________________ Gardeners mailing list [email protected] http://www.lispniks.com/mailman/listinfo/gardeners
