Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
45
Task/Hash-join/Pluto/hash-join.pluto
Normal file
45
Task/Hash-join/Pluto/hash-join.pluto
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
class A
|
||||
function __construct(public age, public name)
|
||||
end
|
||||
end
|
||||
|
||||
class B
|
||||
function __construct(public character, public nemesis)
|
||||
end
|
||||
end
|
||||
|
||||
local tableA = {
|
||||
new A(27, "Jonah"), new A(18, "Alan"), new A(28, "Glory"),
|
||||
new A(18, "Popeye"), new A(28, "Alan")
|
||||
}
|
||||
|
||||
local tableB = {
|
||||
new B("Jonah", "Whales"), new B("Jonah", "Spiders"), new B("Alan", "Ghosts"),
|
||||
new B("Alan", "Zombies"), new B("Glory", "Buffy")
|
||||
}
|
||||
|
||||
local h = {}
|
||||
local i = 1
|
||||
for tableA as a do
|
||||
local n = h[a.name]
|
||||
if n then
|
||||
n:insert(i)
|
||||
else
|
||||
h[a.name] = {i}
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
||||
print("Age Name Character Nemesis")
|
||||
print("--- ----- --------- -------")
|
||||
for tableB as b do
|
||||
local c = h[b.character]
|
||||
if c then
|
||||
for c as j do
|
||||
local t = tableA[j]
|
||||
fmt.print("%3d %-5s %-9s %s", t.age, t.name, b.character, b.nemesis)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue