Here we see the same UUIDv4 generation function written in three different APL(-like) languages: APL, J, and K.
The algorithm is very simple, but one that lends itself well to implementation in an array language:
- Generate a list of 36 random numbers between 0 and 15.
- Transform each of those digits into a single-character string of the corresponding hex digit.
- Join those characters together into a 36-character string.
- Replace some of the characters with dashes.
- Replace the character representing the version nybble with 4 (to indicate a version 4 UUID).
- Constrain the character whose top two bits represent the variant to one that indicates the UUID is an RFC4122 UUID.