Resistance calculator: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 169: | Line 169: | ||
@b.setVoltage @voltage |
@b.setVoltage @voltage |
||
build = ( |
build = (s) -> |
||
stack = [] |
stack = [] |
||
for word in s.split ' ' |
for word in s.split ' ' |
||
Line 175: | Line 175: | ||
else if word == '*' then stack.push new Parallel stack.pop(), stack.pop() |
else if word == '*' then stack.push new Parallel stack.pop(), stack.pop() |
||
else stack.push new Resistor parseFloat word |
else stack.push new Resistor parseFloat word |
||
stack.pop() |
|||
⚫ | |||
node |
|||
node = build |
node = build "10 2 + 6 * 8 + 6 * 4 + 8 * 4 + 8 * 6 +" |
||
⚫ | |||
print " Ohm Volt Ampere Watt Network tree" |
print " Ohm Volt Ampere Watt Network tree" |
||
node.report "" |
node.report "" |