Hash join: Difference between revisions

Added 11l
(Added Prolog)
(Added 11l)
Line 119:
 
<br><hr>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>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)</lang>
 
{{out}}
<pre>
((27, Jonah), (Jonah, Whales))
((27, Jonah), (Jonah, Spiders))
((18, Alan), (Alan, Ghosts))
((28, Alan), (Alan, Ghosts))
((18, Alan), (Alan, Zombies))
((28, Alan), (Alan, Zombies))
((28, Glory), (Glory, Buffy))
</pre>
 
=={{header|AppleScript}}==
1,480

edits