4 ms·
The otherday, I realized that slugging a string is a projection ! It's a surjective map with a reduction of dimensions (aka I give you a slug and in nearly all
by globuous 8y ago
The otherday, I realized that slugging a string is a projection ! It's a surjective map with a reduction of dimensions (aka I give you a slug and in nearly all cases you won't be able to find the original string), and is idempotent, that is, the slug of a slug is itself.
As is, this realization is completely useless since I don't really have any useful way to apply it, but it's a fun way of looking at slugs.
And while we're at it, we can also see that there is a reduction of dimension in the process of hashing but that it is not a projection since the hash of a hash generally isn't itself.
I'm almost sure about what I just said (I'm not a mathematician), but please correct me if I'm wrong !
- joppy 8y agoIt’s a good observation, and the slug(slug(x)) = slug(x) property means that if you have an x and you’re not sure it’s a slug, it’s always ok to slug it to be sure it is. This property can be really handy in building robust systems, where you might have to attempt a couple of times to complete an operation for sure.