Who wants a recursive headache?
One of my very bright students is writing a program to evaluate the total resistance in a network of resistors. She came up with these nested lists to represent the network. The top level is in series and it alternates series and parallel as you go deeper.
[r1, [r2, r3],[[r4, r5,],r6],r7]
That’s r1 + 1/[1/r2+ 1/r3]+ 1/[1/(r4+r5) + 1/r6] + r7
Or
s(r1, p(r2,r3), p(s(r4, r5), r6), r7)
So this ought to be a piece of cake to parse recursively right? right??
This is how we ended up doing it. Not as elegant, but I want to try to help students find a way to make it work in their own framework, not just rewrite everything.
Program to calculate the total value of an arbitrary resistance network represented as a nested list:
Haaretz Editorial: "The freedom from arbitrary arrest marks a line between real, freedom-seeking democracies and 'pseudo democracies.' The police under Ben Gvir’s shadow cannot be relied to give freedom of expression the importance it warrants"
"Haaretz is widely considered Israel's leading liberal news source, but it has published and promoted some of the most harmful propaganda in support of Israel’s genocide in Gaza."