Skip to content

Add getOrPut equivilant to PersistentMap #228

@rnett

Description

@rnett

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions