pamelafox / recursive-visualizations

An online tool to visualize recursive JS functions step-by-step as a tree.
https://www.recursionvisualizer.com/
GNU General Public License v2.0
45 stars 10 forks source link

Issues when using set or dict in parameters #16

Closed jdolivet closed 2 years ago

jdolivet commented 2 years ago

Hello, first of all, thanks for your tool. I'm using it a lot and it's very usefull for my teaching. I like the idea of seeing the parameters in each calls and it seems that it's not possible to see them when they are of type set or dict (it works with list, for example) .In my case, I want to show the recursion calls in a DFS of a Graph. I'm using a class Graphe building as a dict (with a method __str__ or __repr__ for printing him like a dict in the parameters) and a set to keep the nodes. And neither of both is on the function calls. I tried with a method __repr__ to print always the same string and, even like this, the set is appearing just when it's an empty set (set()), when the set is not empty anymore, he's not appearing in the parameters anymore. I suppose the numbers are like id of the functions and it's the default way when the __repr__ or __str__ is not usefull. Maybe it's because both are using the { character...

Is there a way of fixing it?

Not sure if I was clear... Sorry for my english

Thanks

Here is the link of my example

pamelafox commented 2 years ago

I'll check it out now, thanks for linking to the example.

jdolivet commented 2 years ago

Thanks a lot, if it can help : here is the version with a static printing for the class (we can see that the set is being printed just when it's empty) : static for class with set

And same algo with list (working) : static for class with list

But the idea is to do it with set.

My thinking is that it can be linked with f-string because of the { for printing variable... But I don't have enough capacities to understand all the code...

pamelafox commented 2 years ago

I've merged my fix into main, should be live shortly. Please try it out and let me know how that works. You may need to clear your browser cache (I need to implement cache-busting, it appears).