The answer depends on whether you want cycles or not - communicating with them can complicate the situation. But if you want to make a presentation using only lists, then it sharedis your friend. For instance:
(shared ([NY (list "NY" (list London Paris))]
[Paris (list "Paris" (list NY))]
[London (list "London" (list NY))])
(list NY Paris London))
If your goal is to actually write “real” code, then using your own structures will be much better than lists (but then sharedit won’t work).
In the case of using promises, loops become easier to do just with help letrec. Here's what it would look like in this case:
(letrec ([NY (list "NY" (delay (list London Paris)))]
[Paris (list "Paris" (delay (list NY)))]
[London (list "London" (delay (list NY)))])
(list NY Paris London))
Alternatively, you can wrap delayaround each appearance of the city inside the lists.
source
share