Hello,
I'm stumped as to how I create a mutually referential data structure
in Clojure. My compsci is fuzzy. I don't know if what I'm trying to do
is possible. Any insight would be helpful.
I have a function that creates a Person, given his name and a list of
friends.
(defn new_person [name & friends]
{:name name
:friends friends})
But how do I create a mutually referential definition?
ie. what if Bob is Bill's friend, and Bill is also Bob's friend?
I would have to do something like the following: (which is not
allowed)
(def bob (new_person "Bob" bill)) <-Not allowed: forward reference.
(def bill (new_person "Bill" bob))
Thanks a lot for your help
-Patrick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---