RosettaCodeData/Task/Hash-join/11l/hash-join.11l

25 lines
628 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
F hash_join(table1, table2)
DefaultDict[String, [(Int, String)]] h
L(s) table1
h[s[1]].append(s)
[((Int, String), (String, String))] res
L(r) table2
L(s) h[r[0]]
res [+]= (s, r)
R res
V table1 = [(27, Jonah),
(18, Alan),
(28, Glory),
(18, Popeye),
(28, Alan)]
V table2 = [(Jonah, Whales),
(Jonah, Spiders),
(Alan, Ghosts),
(Alan, Zombies),
(Glory, Buffy)]
L(row) hash_join(table1, table2)
print(row)