Oddbean new post about | logout
 This bit of code converts a triple in the form of a nested array into a rudimentary graph.  You can create graphs this way as long as you just use keys.  To hook up the nodes, just reference two IDs as a triple.  I've spent way too much time both learning reduce, but also trying to decide if the simplicity was worth the obscurity in the final code.  The commented bottom three lines are much easier to understand for most, including myself.

https://cdn.fosstodon.org/media_attachments/files/111/055/380/164/802/404/original/66d78d24b9be8195.png