A lot of good ideas here. In the version you shared I also see a pretty good use of `.row` (the screenshot uses raw-row, which could work, but with incorrect syntax. Using .row is a good idea).
I have two kinds of answers for you: (a) the next pedagogic steps based on what Shriram was building up, and (b) some direct remarks to get you unstuck.
I'll focus a little more on (b) with a dash of (a). From looking at your code and the output, I think the dictionary likely has correct results in it, but I can't actually tell. I'd want a shorter example to figure it out and gain confidence that those are the right sums before e.g. publishing it to a class or sharing it with a policy-maker.
One way to approach that is to write a function that takes not just a table, but also a list of the columns to sum, and produces such a dictionary (this is what you've done in top-level code). Then, you could check a few small examples to make sure the sums are producing the results you expect. I think this would be productive and likely make someone *reading* the code understand it better. You could also take another state's data and apply the same function to it, etc.
In terms of the table-based approach you have at the end, there's a difference between how mutable-string-dict and tables work. When Pyret evaluates `set-now` on a MSD, it changes the dictionary “in-place”. When Pyret evaluates `.add-row` on a table, it creates a *whole new table* with the row added.
Without telling you what to write, I think there are a few things I'd suggest:
- Try framing this as a function from a mutable string dict to a table, and think about some examples
- If you get to the point of writing it, there are a few approaches to try:
Overall, great approaches you've arrived at already. I think organizing code into functions so you can write and try small examples, and then trying out some of these other approaches, will give you a productive way forward.
Thanks for the great questions – please follow up with more as they come up!