Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
30
Task/Hash-join/Sidef/hash-join.sidef
Normal file
30
Task/Hash-join/Sidef/hash-join.sidef
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
func hashJoin(table1, index1, table2, index2) {
|
||||
var a = []
|
||||
var h = Hash()
|
||||
|
||||
# hash phase
|
||||
table1.each { |s|
|
||||
h{s[index1]} := [] << s
|
||||
}
|
||||
|
||||
# join phase
|
||||
table2.each { |r|
|
||||
a += h{r[index2]}.map{[_,r]}
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
var t1 = [[27, "Jonah"],
|
||||
[18, "Alan"],
|
||||
[28, "Glory"],
|
||||
[18, "Popeye"],
|
||||
[28, "Alan"]]
|
||||
|
||||
var t2 = [["Jonah", "Whales"],
|
||||
["Jonah", "Spiders"],
|
||||
["Alan", "Ghosts"],
|
||||
["Alan", "Zombies"],
|
||||
["Glory", "Buffy"]]
|
||||
|
||||
hashJoin(t1, 1, t2, 0).each { .say }
|
||||
Loading…
Add table
Add a link
Reference in a new issue