replaceOrAppend
Replace item in array or append if no match
193 bytes
Usage
Given an array of items, an item and an identity function, returns a new array with the item either replaced at the index of the existing item — if it exists, else it is appended at the end.