Anonymous user
Parametric polymorphism: Difference between revisions
m
→{{header|REXX}}: added labels to each of the node's output, added/changed comments and whitespace.
m (→{{header|REXX}}: added labels to each of the node's output, added/changed comments and whitespace.) |
|||
Line 952:
=={{header|REXX}}==
This REXX programming example is modeled after the '''D''' example.
<lang rexx>/*REXX program demonstrates (with displays) a method of parametric polymorphism.
call newRoot 1.00, 3 /*new root, and also indicate 3 stems.*/
/* [↓] no need to label the stems. */
Line 966:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
addStem: nodes=nodes + 1;
newRoot: parse arg @,stems; nodes=-1; call addStem copies('═',9); call addStem @; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
modRoot: arg
do k=1 for stems
if datatype(root.j.k,
end /*k*/
end /*j*/
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
▲ do k=1 for stems; _=_ right(root.j.k, 9)
end /*k*/
end /*j*/ /* [↑] caused by concatenation.*/
say
return /* [↑] extreme indentation to terminal*/</lang>
{{out|output|text= when using the default input:}}
<pre>
═════════ ═════════ ═════════
node=1 1.00 1.00 1.00
node=2 1.10 1.10 1.10
node=3 1.11 1.11 1.11
node=4 1.12 1.12 1.12
node=5 1.20 1.20 1.20
node=6 1.21 1.21 1.21
node=7 1.22 1.22 1.22
═════════ ═════════ ═════════
node=1 51.00 51.00 51.00
node=2 51.10 51.10 51.10
node=3 51.11 51.11 51.11
node=4 51.12 51.12 51.12
node=5 51.20 51.20 51.20
node=6 51.21 51.21 51.21
node=7 51.22 51.22 51.22
</pre>
|