getOrPut is a commonly used function on mutable maps. I would like to have a function to fill the same niche on PersistentMap - creating and adding the new value only if the existing value is not present. This can be done using a contains check and then a put, but that requires two scans of the map, while this method should only require one.
In particular, I'd like it if the method:
- inlined the lambda
- Returned both the new map, and the updated value for the key