Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Now, while it's a bad idea to have a node-and-edges data structure with edges in both directions, it is, of course, nevertheless very useful to be able to navigate in both directions. The Comonad abstraction is very useful for modelling the topology of a data structure, that is, to model which cells are above, below, to the left, and to the right of each other. This abstraction isn't really a new way to represent the data (we can use any of the representations we've discussed above), it's a layer of information we can put on top of the data in order to navigate. My conway repo implements (...but does not really explain) such a 2D array in the context of Conway's Game of Life. I chose to have the array wrap around both horizontally and vertically, but you could also make the world stop at the boundary by giving a different Comonad instance. That's kind of the point: you write a Comonad instance to explain the topology of your structure, including whether it wraps around or not.
You could also have edges pointing up and left in addition to down and right... but then updating any cell would cost O(width*height), because we'd once again have to allocate an entire new array. See my acme-circular-containers package for more information about that kind of approach and why it is a bad idea.
Related posts
- Setting up a Homelab: Part 1 Proxmox and LetsEncrypt
- How to Build Email Server with Exim on Alma Linux 9
- Dehydrated: Letsencrypt/acme client implemented as a shell-script
- Ask HN: What should a Alternative to LetsEncrypt offer
- Setting Up a Kubernetes Cluster on AWS EKS With Eksctl and Deploying an App