Creating a hash of hashes
Posted: Fri Apr 17, 2015 11:30 pm
Hi,
I am confused.
But this seems to be the very first step before being enlightened by the TAO of Lisp...
What I want to do is:
As a parameter to the function I get a list of items, which will become the keys of a "master-hash".
The values of each of the keys will become empty hashes, which I will fill afterwards.
My confusion starts when I think of the way of "ripping of the name of a hash, from the data object as such".
For me it seems that I need kinda "lambda()", but not for functions but for hashes. And if this sounds too
silly...its simply because I am trying to understand this magic language.
For example:
creates a hash for me with 10 empty slots -- the master hash.
This will become one of the sub-hashes. But it already assigns the data object to the symbol/name/variable "sub-hash".
Next step would be something like (WARNING! WRONG CODE AHEAD!)
No...this looks terrible wrong (even for my unknowing eyes
)
I googled the Web and looked into Pratcical Lisp
(http://www.gigamonkeys.com/book/collections.html)
but only found examples, which handles one-dimensional hashes.
How can I create a string from a symbol (how can I get its "name"...) ?
How can I get this working (and myself understand, how its works and why)?
Thank you very much in advance for any help!
Have a nice weekend!
Best regards,
mcc
I am confused.
But this seems to be the very first step before being enlightened by the TAO of Lisp...

What I want to do is:
As a parameter to the function I get a list of items, which will become the keys of a "master-hash".
The values of each of the keys will become empty hashes, which I will fill afterwards.
My confusion starts when I think of the way of "ripping of the name of a hash, from the data object as such".
For me it seems that I need kinda "lambda()", but not for functions but for hashes. And if this sounds too
silly...its simply because I am trying to understand this magic language.
For example:
Code: Select all
(create-hash master-hash :size 10)
Code: Select all
(create-hash sub-hash)
Next step would be something like (WARNING! WRONG CODE AHEAD!)
Code: Select all
(setf (gethash ' masterhash) sub-hash sub-hash )

I googled the Web and looked into Pratcical Lisp
(http://www.gigamonkeys.com/book/collections.html)
but only found examples, which handles one-dimensional hashes.
How can I create a string from a symbol (how can I get its "name"...) ?
How can I get this working (and myself understand, how its works and why)?
Thank you very much in advance for any help!
Have a nice weekend!

Best regards,
mcc