hypot.poqs
· 872 B · Text
Raw
Playground
{ [#port] [@add (x) and (y) into (where)] =>
[% push(vars.where, vars.x + vars.y) %] }
{ [#port] [@square root of (x) into (where)] =>
[% push(vars.where, math.sqrt(vars.x)) %] }
{ [#port] [@write (mesage)] =>
[% io.write(vars.message) %] }
{ [hypotenuse of (a) and (b)] =>
[@square of (a) into {a square is *}]
[@square of (b) into {b square is *}] }
{ [a squared is (a)] [b squared is (b)] =>
[@add (a) and (b) into {a squared plus b squared is *}] }
{ [a squared plus b squared is (c squared)] =>
[@square root of (c squared) into {hypotenuse is *}] }
{ [show results] [hypotenuse is (c)] =>
[@write "The hypotenuse is "]
[@write (c)]
[@write "\n"]
[show results] }
{ [show results} => }
{ =>
[hypotenuse of #3 and #4]
[hypotenuse of #5 and #12]
[hypotenuse of #8 and #15]
[show results] }
1 | { [#port] [@add (x) and (y) into (where)] => |
2 | [% push(vars.where, vars.x + vars.y) %] } |
3 | |
4 | { [#port] [@square root of (x) into (where)] => |
5 | [% push(vars.where, math.sqrt(vars.x)) %] } |
6 | |
7 | { [#port] [@write (mesage)] => |
8 | [% io.write(vars.message) %] } |
9 | |
10 | { [hypotenuse of (a) and (b)] => |
11 | [@square of (a) into {a square is *}] |
12 | [@square of (b) into {b square is *}] } |
13 | |
14 | { [a squared is (a)] [b squared is (b)] => |
15 | [@add (a) and (b) into {a squared plus b squared is *}] } |
16 | |
17 | { [a squared plus b squared is (c squared)] => |
18 | [@square root of (c squared) into {hypotenuse is *}] } |
19 | |
20 | { [show results] [hypotenuse is (c)] => |
21 | [@write "The hypotenuse is "] |
22 | [@write (c)] |
23 | [@write "\n"] |
24 | [show results] } |
25 | |
26 | { [show results} => } |
27 | |
28 | { => |
29 | [hypotenuse of #3 and #4] |
30 | [hypotenuse of #5 and #12] |
31 | [hypotenuse of #8 and #15] |
32 | [show results] } |