[d24f17c] | 1 | var _curry3 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry3.js");
|
---|
| 4 |
|
---|
| 5 | var adjust =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./adjust.js");
|
---|
| 8 |
|
---|
| 9 | var always =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./always.js");
|
---|
| 12 | /**
|
---|
| 13 | * Returns a new copy of the array with the element at the provided index
|
---|
| 14 | * replaced with the given value.
|
---|
| 15 | *
|
---|
| 16 | * @func
|
---|
| 17 | * @memberOf R
|
---|
| 18 | * @since v0.14.0
|
---|
| 19 | * @category List
|
---|
| 20 | * @sig Number -> a -> [a] -> [a]
|
---|
| 21 | * @param {Number} idx The index to update.
|
---|
| 22 | * @param {*} x The value to exist at the given index of the returned array.
|
---|
| 23 | * @param {Array|Arguments} list The source array-like object to be updated.
|
---|
| 24 | * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`.
|
---|
| 25 | * @see R.adjust
|
---|
| 26 | * @example
|
---|
| 27 | *
|
---|
| 28 | * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c']
|
---|
| 29 | * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_']
|
---|
| 30 | * @symb R.update(-1, a, [b, c]) = [b, a]
|
---|
| 31 | * @symb R.update(0, a, [b, c]) = [a, c]
|
---|
| 32 | * @symb R.update(1, a, [b, c]) = [b, a]
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | var update =
|
---|
| 37 | /*#__PURE__*/
|
---|
| 38 | _curry3(function update(idx, x, list) {
|
---|
| 39 | return adjust(idx, always(x), list);
|
---|
| 40 | });
|
---|
| 41 |
|
---|
| 42 | module.exports = update; |
---|