myrmepropagandist on Nostr: Who wants a recursive headache? One of my very bright students is writing a program ...
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??
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??