import { modifyAt } from "https://deno.land/x/fun@v2.0.0-alpha.6/array.ts";
Create a new array by modifying a value of an array at an index. If the index is out of range of the existing array then no change is made.
Examples
Example 1
Example 1
import * as A from "./array.ts";
import { pipe } from "./fn.ts";
const inc = (n: number) => n + 1
const modifyAt = A.modifyAt(0); // Modify value at
const arr = [1, 2, 3];
const result1 = pipe(arr, modifyAt(inc)); // [2, 2, 3]
const result2 = pipe(arr, A.modifyAt(100)(inc)); // [1, 2, 3]