RosettaCodeData/Task/Hash-join/PureBasic/hash-join.basic

48 lines
1.1 KiB
Plaintext

Structure tabA
age.i
name.s
EndStructure
Structure tabB
char_name.s
nemesis.s
EndStructure
NewList listA.tabA()
NewList listB.tabB()
Macro SetListA(c_age, c_name)
AddElement(listA()) : listA()\age = c_age : listA()\name = c_name
EndMacro
Macro SetListB(c_char, c_nem)
AddElement(listB()) : listB()\char_name = c_char : listB()\nemesis = c_nem
EndMacro
SetListA(27, "Jonah") : SetListA(18, "Alan") : SetListA(28, "Glory")
SetListA(18, "Popeye") : SetListA(28, "Alan")
SetListB("Jonah", "Whales") : SetListB("Jonah", "Spiders")
SetListB("Alan", "Ghosts") : SetListB("Alan", "Zombies")
SetListB("Glory", "Buffy")
If OpenConsole("Hash_join")
ForEach listA()
PrintN("Input A = "+Str(listA()\age)+~"\t"+listA()\name)
Next
PrintN("")
ForEach listB()
PrintN("Input B = "+listB()\char_name+~"\t"+listB()\nemesis)
Next
PrintN(~"\nOutput\nA.Age\tA.Name\tB.Char.\tB.Nemesis")
ForEach listA()
ForEach listB()
If listA()\name = listB()\char_name
PrintN(Str(listA()\age)+~"\t"+listA()\name+~"\t"+
listB()\char_name+~"\t"+listB()\nemesis)
EndIf
Next
Next
Input()
EndIf