Hash join: Difference between revisions
→{{header|TXR}}: group-by solution.
(→{{header|TXR}}: Use new append-each* operator.) |
(→{{header|TXR}}: group-by solution.) |
||
Line 913:
<pre>$ txr hash-join.txr
((27 Jonah Whales) (27 Jonah Spiders) (28 Alan Ghosts) (18 Alan Ghosts) (28 Alan Zombies) (18 Alan Zombies) (28 Glory Buffy))</pre>
Using the unreleased TXR in git, it is be possible to replace the construction of the <code>name-hash</code> with a one liner, eliminating the block of code which walks the tuples and pushes them into buckets based on hashing the name:
<lang txr>(defvar name-hash [group-by second age-name])</lang>
The <code>group-by</code> function, which will be officially released in TXR 76, is inspired by Ruby solution; it seems worth including in the programming language.
|