Anonymous user
Hash join: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, changed indentations.
(Ruby restored because it was overwritten by mistake.) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations.) |
||
Line 1,595:
=={{header|REXX}}==
<lang rexx>/*REXX program demonstrates the classic hash join algorithm for two relations. */
S. =
S.1 = 27 'Jonah'
S.2 = 18 'Alan'
S.3 = 28 'Glory'
S.4 = 18 'Popeye'
S.5 = 28 'Alan'
hash.= /*initialize the hash table (array). */
#=#-1 /*adjust for the DO loop (#) overage.*/
S.#=',' x /*add a new name to the S table. */
hash.x=# /* " " " " " " hash " */
_='─' /*the character used for the separator.*/
pad=left('',
say pad center('age', 3) pad center(
say pad center('───', 3) pad center(
do n=1 for #; parse var S.n age name nems /*
if nems=='' then iterate /*No nemesis? Skip. */
say pad
end /*n*/ /*stick a fork in it, we're all done. */</lang>▼
'''output''' when using the in-code relations (data):▼
▲ /*stick a fork in it, we're all done. */</lang>
▲'''output''' using the in-code relations (data):
<pre>
age name nemesis
─── ──────────────────── ──────────────────────────────
27 Jonah Whales Spiders
18 Alan Ghosts Zombies
28 Glory Buffy
28 Alan Ghosts Zombies
</pre>
|