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
23
Task/Hash-join/LFE/hash-join-1.lfe
Normal file
23
Task/Hash-join/LFE/hash-join-1.lfe
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
(defun hash (column table)
|
||||
(lists:foldl
|
||||
(lambda (x acc)
|
||||
(orddict:append (proplists:get_value column x) x acc))
|
||||
'()
|
||||
table))
|
||||
|
||||
(defun get-hash (col hash-table)
|
||||
(proplists:get_value
|
||||
(proplists:get_value col r)
|
||||
hashed))
|
||||
|
||||
(defun merge (row-1 row-2)
|
||||
(orddict:merge
|
||||
(lambda (k v1 v2) v2)
|
||||
(lists:sort row-1)
|
||||
(lists:sort row-2)))
|
||||
|
||||
(defun hash-join (table-1 col-1 table-2 col-2)
|
||||
(let ((hashed (hash col-1 table-1)))
|
||||
(lc ((<- r table-2))
|
||||
(lc ((<- s (get-hash col-2 hashed)))
|
||||
(merge r s)))))
|
||||
11
Task/Hash-join/LFE/hash-join-2.lfe
Normal file
11
Task/Hash-join/LFE/hash-join-2.lfe
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
> (set ss '((#(age 27) #(name "Jonah"))
|
||||
(#(age 18) #(name "Alan"))
|
||||
(#(age 28) #(name "Glory"))
|
||||
(#(age 18) #(name "Popeye"))
|
||||
(#(age 28) #(name "Alan"))))
|
||||
|
||||
> (set rs '((#(nemesis "Whales") #(name "Jonah"))
|
||||
(#(nemesis "Spiders") #(name "Jonah"))
|
||||
(#(nemesis "Ghosts") #(name "Alan"))
|
||||
(#(nemesis "Zombies") #(name "Alan"))
|
||||
(#(nemesis "Buffy") #(name "Glory"))))
|
||||
8
Task/Hash-join/LFE/hash-join-3.lfe
Normal file
8
Task/Hash-join/LFE/hash-join-3.lfe
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
> (hash-join ss 'name rs 'name)
|
||||
(((#(age 27) #(name "Jonah") #(nemesis "Whales")))
|
||||
((#(age 27) #(name "Jonah") #(nemesis "Spiders")))
|
||||
((#(age 18) #(name "Alan") #(nemesis "Ghosts"))
|
||||
(#(age 28) #(name "Alan") #(nemesis "Ghosts")))
|
||||
((#(age 18) #(name "Alan") #(nemesis "Zombies"))
|
||||
(#(age 28) #(name "Alan") #(nemesis "Zombies")))
|
||||
((#(age 28) #(name "Glory") #(nemesis "Buffy"))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue