Array.with(): Immutable Index Update

Change one wagon three ways: arr.with(i, v) brings a new train and Mr. Wiryo copies everything, arr[i] = v reloads train #1 itself, and the manual slice way…

The key idea

arr.with(i, v) is the non-mutating twin of arr[i] = v

Try it in this playground