[Question]
  [
Given:
* a [blackbox function](https://codegolf.meta.stackexchange.com/a/13706/66833) \$f : \mathbb N \to \mathbb N\$,
* a list of positive integers \$L\$, and
* a list of indices \$I\$,
apply \$f(x)\$ to the elements of \$L\$ at the indices specified in \$I\$.
For example, \$f(x) = x^2, L = [7, 6, 3, 9, 1, 5, 2, 8, 4]\$ and \$I = [3, 5, 8]\$ (using 1 indexing), we apply \$f(x)\$ to the 3rd, 5th and 8th elements, yielding \$[7, 6, 9, 9, 1, 5, 2, 64, 4]\$
---
You may use 0 or 1 indexing for \$I\$. The elements of \$I\$ will be unique (there will be no duplicates), the maximum element of \$I\$ will never exceed the length of \$L\$ (or the length of \$L\$ minus 1, if using 0 indexing) and the minimum will never be below 1 (or 0, for 0 indexing).
Neither \$I\$ nor \$L\$ will ever be empty. \$f\$ will always return a positive integer, and will always take a single positive integer. \$L\$ may be in any order, however, you may decide if \$I\$ is in any specific order (e.g. sorted ascending).
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes
---
## Test cases
```
f(x)
L
I (using 1 indexing)
out
f(x) = x¬≤
[14, 14, 5, 15, 15, 10, 13, 9, 3]
[1, 3, 4, 5, 6, 7]
[196, 14, 25, 225, 225, 100, 169, 9, 3]
f(x) = x+1
[7, 12, 14, 6]
[1, 2, 3, 4]
[8, 13, 15, 7]
f(x) = œÉ‚ÇÄ(x)+x
[13, 11, 9, 15, 16, 16, 16, 11, 6, 4]
[2, 4, 6, 8, 10]
[13, 13, 9, 19, 16, 21, 16, 13, 6, 7]
```
where \$\sigma\_0(x)\$ is the [number of divisors function](https://en.wikipedia.org/wiki/Divisor_function).
This is a builtin in Jelly. [This](https://tio.run/##y0rNyan8f7gtRfv/4fZHTWseNe48tOz/o8Yth7YGVSQ83NX1cMfiiIc7Ww5t9YJwfCJUHu5cBBQ5vNzh/38LAA) is a program where you can modify the function \$f\$ in the Header, and it will generate a random `L`, `I` then `out` on separate lines. The final test case is prefilled into the Header.
  
[Answer]
# [Scratch 3](https://scratch.mit.edu), ~~16~~ 13 blocks
[![enter image description here](https://i.stack.imgur.com/ocNtF.png)](https://i.stack.imgur.com/ocNtF.png)
[Try it online!](https://scratch.mit.edu/projects/525686367)
Scratch functions can't `return`, so the function `f` must edit variable `x`.
[Answer]
# [Python 3](https://docs.python.org/3/), 38 bytes
```
def f(p,a,i):
	for q in i:a[q]=p(a[q])
```
[Try it online!](https://tio.run/##NYuxCoMwFEXn5ivumMgbrGkLDfglIcMrGhpoYxQH/fr4pHQ4nDucW/b1PWVb6zBGRF2IKRmnLnFaMCNlJMd@Dn3Rp0xl9PDXG@HkLvrTCpbwJNigov7w9zUwNocNTYOOwAQvkSzJfudHMKosKa@aTT0A "Python 3 ‚Äì Try It Online")
-16 bytes using in-place thanks to dingledooper
# [Python 3](https://docs.python.org/3/), 51 bytes
```
def f(p,a,i):exec("a[i.pop(0)]=p(a[i[0]]);"*len(i))
```
[Try it online!](https://tio.run/##NYvBCsIwEETv/Yqlp92wSDUqWOmXhBxWm2CgpkF6iF8fV8TDY2bgTXlvjzXb1uYQIWJh4URjqOGOvbi0K2vBgfxUUJcbvKdrb5aQMRE1gQnc/sjw5aTxZ1Asw4XB@i7iIs/bLFBHqGAMHBiEwamkTbXf@eypK6@UNxRqHw "Python 3 ‚Äì Try It Online")
Inlining with `exec` does not make it any shorter. But oh well, it was an idea :P
[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 104 bytes
```
(d g(q((L I F _)(i L(c(i(e(h I)_)(F(h L))(h L))(g(t L)(i(e(h I)_)(t I)I)F(a _ 1)))L
(q((F L I)(g L I F 0
```
The solution is the unnamed lambda function represented by the second line. Uses 0-indexing. Requires that the list of indexes be sorted ascending. [Try it online!](https://tio.run/##dVHRaoNAEHzPVwz0ZZdS8LzEkKe8BCEg/kIwatKDS0zUFPL1djdaTUMLiyczs@Pc2Lrz3bvm0nVU4EhXogRbxNgxOSSUk6OSPrFlAWJ5SZiH55FaOZ/5Vo4tx5RhB8PMyUw8D@oZQ1xlBb150JGvsgLe7eusvvNMhOUBzfWW1SXIZ6d9kYFSBp1uPkSKVOx6kTegK8jMIbOA6SeAsVjBjjLXywKEsFBhpNRgET64JUyoJtG0JETQVmozSHd5dTu3H4X7ck1VN0/ZsMGb5HMHUCm5/VpSbhQ45w/idTPtqc2wo3hRNmuxSaetN@YxzL9f/tPcIJgqsn1FFsZIKdpP9DMGEebThQeldLTAEqtHR97MaPwZUrczAjaXXJhQGc0qFbpwhK3CvwK@631fQ4q7ZnOWu28 "tinylisp ‚Äì Try It Online")
### Explanation
Our approach is to define a helper function `g` that takes a fourth argument representing the current index. Then we walk through the list recursively, incrementing the index each time. If the current index matches the head of the list of indices, we call the function on the head of the list of values and cons the result to the recursive call; otherwise, we cons the value unchanged.
Ungolfed:
```
(load library)
(def _helper
  (lambda (func ls indices index)
    (if ls
      (cons
        (if (equal? (head indices) index)
          (func (head ls))
          (head ls))
        (_helper func
          (tail ls)
          (if (equal? (head indices) index)
            (tail indices)
            indices)
          (add2 index 1)))
      nil)))
(def apply-at-indices
  (lambda (func ls indices) (_helper func ls indices 0)))
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
√á·πõ¬°"·π¨}
```
[Try](https://tio.run/##y0rNyan8f2jT/8PtD3fOPrRQ6eHONbX///@PNjTRUQBhUyAFwwZAbKyjYKmjYBwLVAGkdBQgSsx0FMxjAQ "Jelly ‚Äì Try It Online") [it](https://tio.run/##y0rNyan8/6hhxv/D7Q93zj60UOnhzjW1////jzbXUTA0AmITHQWz2P/RhjoKQJ6xjoJJLAA "Jelly ‚Äì Try It Online") [online!](https://tio.run/##y0rNyan8f7gtRfv/4faHO2cfWqj0cOea2v///0cbGusoGBrqKFgCKVMgNkPCQGEgZRL7P9oISIE5FkBhg1gA "Jelly ‚Äì Try It Online")
For the sake of not leaving anything too important in the comments, the built-in solution is `√á‚Ç¨‚Åπ¬¶`.
```
   "      For each element of the left argument and each corresponding element of
    ·π¨}    a list of ones at the indices in the right argument and zeroes elsewhere,
√á         apply the given function to the left element
  ¬°       a number of times equal to
 ·πõ        the right element.
   "      (For elements of the left argument past the end of the right argument, leave them unchanged.)
```
[Answer]
# [JavaScript (V8)](https://v8.dev/), 31 bytes
```
(a,g,p)=>p.map(i=>a[i]=g(a[i]))
```
[Try it online!](https://tio.run/##rZDBboMwEETv/oo54tQ02GkhBJkq34E4WBSQKxUs46D066ldpznlmMPsSusdzfN@qVUtndXGpetxG@SWKDYyQ2VtXr@VSbSsVaPbj1DkmIRGTxndVmWhrFU/kGj4G0PQu2//yrwODCXDoa0IGZK/bYYrZO3LbgfBvNM/M0RrzlC0MTTsaKTglFbY73HuuvkyOQyzBU/19Nlf9TRiHuD6xaFTS78QYqyeXMyhFUEwNrzMI5vwCeJeeBb48vIGSMj9L4Wfi2jJH4G/gEduEdGfTnyMhwtHLNrtFw "JavaScript (V8) ‚Äì Try It Online")
Produces output by modifying the input array in place.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 8 bytes
```
ZL√•√Ö√ès.V
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/yufw0sOth/uL9cL@/4820jHRMdOx0DE0iOWKNjTWMTTUsdQxNNUxNIMhQ6C8SSyXy@GJ6doA "05AB1E ‚Äì Try It Online") Uses 1-based indexing.
```
ZL√•√Ö√ès.V  # full program
   √Ö√è     # for elements in...
          # implicit input...
   √Ö√è     # where corresponding element in...
  √•       # is...
          # (implicit) each element in...
 L        # [1, 2, 3, ...,
Z         # ..., largest element of...
          # implicit input...
 L        # ]...
  √•       # in...
Z         # implicit input...
   √Ö√è     # is 1 replace current element in map with...
      .V  # result of running...
     s    # implicit input...
      .V  # as 05AB1E code
          # (implicit) exit map
          # implicit output
```
[Answer]
# [J](http://jsoftware.com/), 13 bytes
```
1 :'u@{`[`]}'
```
[Try it online!](https://tio.run/##TY1BC4JAEIXv/opHl3VrFUdNc6GIgk7RoatEQmnZwQ4iBNFv30a3Ipg3MG/efHMzI19UmGsIKATQLM/Her/dGIIW3fJZ5MXhJYx0disfXVu2HKmbc/mom4tTnq53uJQlChQrhFPWr1EQcEsyBa5IwtNwj4QJiEcFznOIL1MJd6xRyYFB1qevekZkEZ93M@v02/SfihARYoYtBljKkdDyEvMG "J ‚Äì Try It Online")
An adverb modifying the function, taking the 0-based indexes as left arg and `L` as the right arg. Called like:
```
indexes  black box function
   v     v  
0 1 2 3 (>: f) 7 12 14 6
               ^
               list L to transform
```
This is just a very thin wrapper over the gerund form of J's Amend adverb, using `{` to pluck the values we want to transform and then applying our black box function to them `@u`.
[Answer]
# [Factor](https://factorcode.org/) + `math.unicode`, 50 bytes
```
[ '[ _ ‚àà [ call ] [ drop ] if ] with map-index ]
```
[Try it online!](https://tio.run/##JY6xCsIwGIT3PsVtTpbWqqA@gLi4iFMoEtK/GIxpmqRoke59Tl8kphWO44Pvhqu58I0N18vpfNzjyf19rrTTUjQVobY9HmQ1KThqO9KCHIwl73tjpfY4JAmDa1EmH@TrKRvk/2TIC@xQYIguwyrSZLcYAsOC4YbvOIJBcKVQRqhsYyLIOtZLzlfMUuqK3ijDvErDDw "Factor ‚Äì Try It Online")
## Explanation:
It's a quotation (anonymous function) that takes a quotation with stack effect `( x -- x )`, a sequence of values, and a sequence of 0-indexed indices (in that order) from the data stack as input and leaves a sequence of results on the data stack as output. Assuming `[ sq ] { 4 5 } { 0 }` is on the data stack when this quotation is called...
* `'[ _ ‚àà [ call ] [ drop ] if ]` Place a quotation on the stack for `with` to use later. However, `'` starts a *fried* quotation, which says to slot whatever is on top of the data stack into the `_`. When `_` appears on the left side of a quotation like this, it's just a shorthand for `curry`ing a quotation.
**Stack:** `[ sq ] { 4 5 } [ { 0 } ‚àà [ call ] [ drop ] if ]`
* `with` Partial application on the left. It sticks the `[ sq ]` into the quotation in such a way that it comes *before* whatever the following combinator puts on top of the data stack.
**Stack:** `{ 4 5 } [ [ sq ] [ { 0 } ‚àà [ call ] [ drop ] if ] swapd call ]`
* `map-index` Apply a quotation to each element of a sequence, collecting the results into a sequence of the same size. However, `map-index` will also place the index of the element being mapped on top of the data stack. Inside the quotation during the first iteration now...
**Stack:** `4 [ sq ] 0 { 0 } ! element, function, index, indices`
* `‚àà` Shorthand for `member?` Returns `t` if the object second from the top is in the sequence on top of the stack.
**Stack:** `4 [ sq ] t`
* `[ call ] [ drop ]` Push some quotations for `if` to use later.
**Stack:** `4 [ sq ] t [ call ] [ drop ]`
* `if` If third from the top is `t`, call the first quotation, otherwise call the second.
**Stack:** `16`
* Now `map-index` collects this result into the sequence it's building and proceeds with the next iteration.
**Stack:** `5 [ sq ] 1 { 0 }`
* This time, the index is not found in the indices, and so `[ sq ]` gets `drop`ped instead of `call`ed.
**Stack:** `{ 16 5 }`
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 6 bytes
Full program which is just a thin cover for [the built-in `@` ("At") operator](https://help.dyalog.com/latest/Content/Language/Primitive%20Operators/At.htm). Uses whichever indexing APL currently uses (can be 0 or 1).
```
‚éï¬®@‚éï‚ä¢‚éï
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO94P@jvqmHVjgAyUddi4AkSPC/AhgUcBma6CiAsCmQgmEDIDbWUbDUUTDmMgQSOgoQBWY6CuZc1Y96t2oZ1XLBDDAHKjaCmGEGUm0E0QBWp22IUAcy0dAQbCrYEjMkbAg224TLCGwTkGkBcgXEiEedix51rAKyHnWseNS7GcioBQA "APL (Dyalog Unicode) ‚Äì Try It Online")
`‚ä¢‚éï`‚ÄÉon \$L\$
`@‚éï`‚ÄÉat indices \$I\$
`‚éï¬®`‚ÄÉapply \$f\$ to each
---
Without the built-in:
```
L‚Üê‚éï
L[I]‚Üê‚éï¬®L[I‚Üê‚éï]
L
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO94L/Po7YJj/qmcvlEe8ZCmIdWANkQZiyXD0jVfwUwKOAyNNFRAGFTIAXDBkBsrKNgqaNgzGUIJHQUIArMdBTMuaof9W7VMqrlghlgDlRsBDHDDKTaCKIBrE7bEKEOZKKhIdhUsCVmSNgQbLYJlxHYJiDTAuQKiBGPOhc96lgFZD3qWPGodzOQUQsA "APL (Dyalog Unicode) ‚Äì Try It Online")
`L‚Üê‚éï`‚ÄÉget \$L\$
`L[`‚Ä¶`]`‚ÄÉextract the following elements from \$L\$:  
‚ÄÉ`I‚Üê‚éï`‚ÄÉget \$I\$  
`‚éï¬®`‚ÄÉget \$f\$ and apply it to each  
`L[I]‚Üê`‚ÄÉlet those values replaces the values in \$L\$ at indices \$I\$
`L`‚ÄÉprint the updated \$L\$
[Answer]
# [R](https://www.r-project.org/), 38 bytes
```
function(l,i,f){l[i]=sapply(l[i],f);l}
```
[Try it online!](https://tio.run/##K/qfrmCj@z@tNC@5JDM/TyNHJ1MnTbM6Jzoz1rY4saAgp1IDxAaKWefU/k/XMLQyNNAxtDLVMtKB66nQrIgz0vwPAA "R ‚Äì Try It Online")
1-based indices.
If we can assume that `f` is vectorized (perhaps by use of `Vectorize()`), then this would be 31 bytes:
```
function(l,i,f){l[i]=f(l[i]);l}
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
z?‚Å∞IM‚Ç¨N
```
[Try it online!](https://tio.run/##yygtzv6v8Kip8dG0hf@r7B81bvD0fdS0xu/////RhjrGOiY6pjpmOuaxQJ6JjiGIZwhBBjqGxjqWOsaxAA "Husk ‚Äì Try It Online")
Husk probably needs a builtin for this and/or for converting a list of indices into a boolean mask.
### Explanation
```
z?‚Å∞IM‚Ç¨N    Inputs: function, indices, list of values
    M‚Ç¨N    Build a list saying for each natural number if it is present in the indices
z          Pair each element of this list to one of the values and
 ?          if it is truthy
  ‚Å∞          apply the input function
   I        else, apply the identity function (leave the value unchanged)
```
[Answer]
# [Raku](http://raku.org/), 17 bytes
```
{@^h[@^i]¬ª.=&^f}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/2iEuI9ohLjP20G49W7W4tFqQjENiUVFipYKtQrShiY4CCJsCKRg2AGJjHQVLHQXjWGuFNA2tQ5t0oFp0FGwMFIwUjBVMFEwVzOw0rRWKE2HG/QcA "Perl 6 ‚Äì Try It Online")
0-based indexing. Modifies the input array in-place.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 33 bytes
```
->g,l,i{i.map{|x|l[x]=g[l[x]]};l}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5dJ0cnszpTLzexoLqmoiYnuiLWNj0aRMXWWufU/i9QSIvWtcurztPKq9WJNjTRUQBhUyAFwwZAbKyjYKmjYByrEw3kGQFZOgoQVWaxsf@jDS3NINqMgCJGcMLQAKTVzBKqFwA "Ruby ‚Äì Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~46~~‚Ä¶ 44 bytes
* -1 byte thanks to [Unrelated String](https://codegolf.stackexchange.com/users/85334/unrelated-string), by reminding me that infix is not always better.
* -1 byte thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor), by suggesting `take`/`drop` instead of `splitAt`.
```
foldl.h
h f l i=take i l++f(l!!i):drop(i+1)l
```
[Try it online!](https://tio.run/##ZY1Na4NAEIbv/ooh9KBkNsRNIyiu0GOhtx5NAuLHunTiim7BQn97NyNpS6GHd2f24X2YvprfWiKv1cl3lhra9UEPHRCYz3DB9@wjysU8knFPDgyQWrbbDhj7a2UG1dgAKBdTWzX5Q6Fb92KGNgCTi3BlWfbqJjNoUZTPgztHfzv2vzZy14U6vMiI7ytlcbNc5AYJDdrIl/Ejwpojj5/sOQeEFOFwDkr@Sd4Q7q2EUZwmd0sykL9PvF/NJP1Wv@qOKj17UY/jDQ "Haskell ‚Äì Try It Online")
The relevant function is `foldl.h`, which takes as input `f`, `l`, `i`. The list of indices `i` is `0`-indexed.
## How?
```
h f l i=take i l++f(l!!i):drop(i+1)l
```
The function `h` applies `f` to the `i`-th element of the list `l`. Since Haskell is very unappreciative of mutable variables, the only way to do it is concatenating the first `i` elements of `l`, then `f` applied to the `i`-th element, and finally the rest of `l`.
---
```
foldl.h‚â°\f l i->foldl(h f)l i
```
This repeats the previous function for all the indices in the input list `i`.
---
# [Haskell](https://www.haskell.org/), 33 bytes
```
foldr.adjust
import Data.Sequence
```
[Try it online!](https://tio.run/##fYtNC4IwHIfv@xQjOihsoqsEQzt1Cbp1tIKhc63mZnNCn7416YUg6PD7v/x4nhPtL0xKJ9pOGwvX1NJox64DUxUDvNi7RsvaRLQ@D70FGP9SrqVCFbUGUOa4Mbrdit5GhtE6n644s1uhGIAix8HYLZc7a4TieFVulD2E34z@43desgEPjiSUUBSFRpPbkUyQRALp0JXJHMExC7/eiX1mCGYIzg6g9B/xF4JPKvVVkqVPi/iCfEYSj2aavdR71UjKe4errnsA "Haskell ‚Äì Try It Online")
Basically the same solution, but uses the `Seq` type from `Data.Sequence` instead of a `List`. The `import` is costly, but the `h` function from the above solution is already implemented as `adjust`.
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 10 bytes
```
{ùîΩ‚åæ(ùï®‚ä∏‚äè)ùï©}
```
[Try it online!](https://mlochbaum.github.io/BQN/try.html#code=X0Yg4oaQIHvwnZS94oy+KPCdlajiirjiio8p8J2VqX0KCjHigL8zIOKIml9GIDHigL8y4oC/M+KAvzTigL82)
To show off structual under `‚åæ` which is a little bit more powerful than J's `&.` as I found out yesterday. `{‚Ä¶}` defines a block where we get access (among other things) to `ùï©` as the right argument, `ùï®` the left, and `ùîΩ` the function that gets modified. So this calls `ùîΩ‚åæ(ùï®‚ä∏‚äè)` with `ùï©`. `‚åæ` executes the right part, then the left part, and then the inverse of the right part. But unlike `&.` it also remembers the original array at the inverse step, so it can be used to update the array. So `ùï®‚ä∏‚äè` takes the elements of `ùï©` at the indices of `ùï®`. On these elements `ùîΩ` gets called. Then the elements get re-inserted into the original arrays at the indices of `ùï®`.
[Answer]
# x86-16 machine code, 11 bytes
```
        I_LOOP: 
AD          LODSW                       ; next index into AX 
97          XCHG AX, DI                 ; index in DI 
8A 01       MOV  AL, BYTE PTR[BX+DI]    ; AL = value of L 
FF D5       CALL BP                     ; call BlackBox (tm) function 
88 01       MOV  BYTE PTR[BX+DI], AL    ; value of L = AL 
E2 F6       LOOP I_LOOP                 ; loop until end of I  
C3          RET                         ; return to caller
```
`L` list at `[BX]`, `I` list at `[SI]` (zero indexed), `I` length in `CX`. BlackBox function at `[DS:BP]`, input value/return in `AL`.
Example run with DEBUG. The "interesting" parts have been highlighted for those who don't speak DEBUG.
[![enter image description here](https://i.stack.imgur.com/3vrhR.png)](https://i.stack.imgur.com/3vrhR.png)
[Answer]
# [Lua](https://www.lua.org/), 67 bytes
```
function g(f,l,i)for k,v in pairs(i)do l[v]=f(l[v])end return l end
```
[Try it online!](https://tio.run/##XYzNCsIwEITveYqhpwSWotYfPPRJRKHYRBZDIrGJBemz15RaDx6GWdj5Phub0dbv9ZYwZZdrySqnIhwJ1SA4b/JBmEd7wmEQJrprx97ByF4F3cXg0F820K4df7@bNGSJlfEBd0pgh0fD4SlZtR72lM61kVOpjOFrsbPjH1lcmRTsy1fgTstUlgUVSkzEBw "Lua ‚Äì Try It Online")
Uses 1-indexing, i always forget lua uses 1 indexed tables
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 14 bytes
```
Yd{diyI^n_aaMm
```
[Run and debug it](https://staxlang.xyz/#c=%7BYd%7BdiyI%5En_aaMm%7DXd%0A%0A%7BJ%7D%22%5B14,+14,+5,+15,+15,+10,+13,+9,+3%5D%5B0,+2,+3,+4,+5,+6%5D%22ex%21JP%0A%7B%5E%7D%22%5B7,+12,+14,+6%5D%5B0,+1,+2,+3%5D%22ex%21JP%0A%7Bc%3Ad%25%2B%7D%22+%5B13,+11,+9,+15,+16,+16,+16,+11,+6,+4%5D%5B1,+3,+5,+7,+9%5D%22ex%21JP%0A&i=)
The fully manual method, takes args as `block arr arr`. Requires 0-indexed indices.
the final result is put on the top of the stack.
The single byte builtin for this which takes args `arr arr block` is `&`.
[Answer]
# [Icon](https://github.com/gtownsend/icon), 43 bytes
```
procedure a(L,I,f)
L[k:=!I]:=f(L[k])&\z
end
```
[Try it online!](https://tio.run/##jZBBDoIwEEX3PcXAwrTahYBCxHAAkt4AWRAoSWMsUkDRy2Nro6Irm/x0JvPyf2ZE2chpOqum5NWgOBSY0ZTWBLHsGCdOmsdJjXWdk8XhjrisZmzX4pEg0E/xflASxuVoEIQ@jJDlL7TyfqFTISS2EIuTzNtQMNrq76W1VkBhRyHIn2BqQN1RsGRIIbITu0LXWkN@4eoGVyV63mGHURdcsre9jnxnRtrft7HhV4BvM@bWeqd/vM2xHg "Icon ‚Äì Try It Online")
[Answer]
# C#, 50 bytes
```
(f,L,I)=>L.Select((v,i)=>I.Contains(i+1)?f(v):v);
```
Online demo: <https://dotnetfiddle.net/M4YbOx>
[Answer]
# Scala 3, 50 bytes
```
f=>I=>_.zipWithIndex.map((?,i)=>if(I(i))f(?)else?)
```
[Try it in Scastie!](https://scastie.scala-lang.org/NVu7zufdTbaRXbOz0ggaCA)
Stupid function parameter names ftw! Indexing starts at 0.
```
f=>  //The blackbox function
I=>  //The Set of indices
 _   //The list of integers
 .zipWithIndex //Zip each element with its index
 .map((?,i)=>  //Map each element `?` and its index `i`
   if(I(i))    //If the Set of indices contains i
    f(?)       //apply f to ?
    else ?     //Otherwise, just return ?
 )
```
[Answer]
# Java, ~~42~~ 38 bytes
```
(a,i,f)->{for(int j:i)a[j]=f.f(a[j]);}
```
*Saved 4 bytes thanks to [Olivier Gr√©goire](https://codegolf.stackexchange.com/users/16236).*
[Try it online!](https://tio.run/##jVLBTsMwDL33K3xsURYBAySoNokLN8Rh4jTtELpkSumSKnHLpmrfXpwmAwEXLFlJ/OznZ7e16MWs3r6Pet9ah1DTm3eoG/7onDj6MvsDqM5UqK3hr0a440srnUDryixru7dGV1A1wnt4FtrAkAGZNiidEpWElW166WDord6CD4@cwPUGhHMM4lWbra6kZ/CU@oAqytMvojM2UAhUICGw7fCc6VEgSUn9fDwWYy6YZqqYLQdl3VRVP@hCrOvNQnGVhwsxjIGhnHjSSIlukr2nwfIVOm12k/CdL@KYwVB6zI38iLMMVzcMgt/ScfZL8jmDewbzE4PvXIpfU4xBzL8j8DBbHi4ORZQSB2ud7gXKH4qmpv/a47fQuBIev0GqSvkqNQy2OnqUe2475NTZYGPy@F9wtHEHobj4kngaPwE)
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~54~~ \$\cdots\$ ~~52~~ 43 bytes
Saved 9 bytes thanks to [att](https://codegolf.stackexchange.com/users/81203/att)!!!
```
f(g(),*L,*I,n){for(;n--;)L[*I++]=g(L[*I]);}
```
[Try it online!](https://tio.run/##fVTbjtowEH3nK0aRqGJjVGx22dJs2odqV0LiD1iEolzYqJClCbRREb9eOmPHuS0tkpPYc86ZC@MJx@EuyLbXa@JuXSb4UvCFyNg5ectdLxuPPbZc8cVotPa3Ln2tmXe5ptkRih@5WzI4Qx4fT3kGJXAoPbgMyHjYnYqN7NlHIK29SLf7YLIhWGlQdJqDD8oDdA0u7SOzj@CRlEejiCFk5EM5jHx/4lllPDOeDzmyiMkDoQV3pFzLpSiHrBTldiSXMtCMxHWGxTByhJt@dQQ4nx2HCQhWKeaKqjrgfZBmWiTIt6GA8DXIOafNTzY4DwB/ZHR5csrCYrVmhGXo74xlElU5RCfti6dpWgmItsmCfYxcYjkl54pi0VWjD0OlWmGyTkUmn8e4OE4MS94JoHWPL7smuKYC5gKmPZI0pAcEKMOb9RCqkkW@lFpDS85aC4/xddcQuWZWaejYhPFmXqrnYrMzyCL9Hb8lriawj9WOmy3VrbbKrlV2raprVazlLs2iqk4YEmaMWZlazbogWYOkwXXNtihaANlYv3k7fYSkof0fyafQovqpulK95AncxK93dXIk0bHJjk11bJ204/IQh8fY5i7nM/NnK4xd1Q85oXxn83edYulVVT6ZdqI@eLiBaneM6To5N52iZNUxU90xD@2SWbYh1wGLxnnzqTr3JnyNw@9xjkTQ1@alfFIv5fwbrnu6Na391F6aZh5kUVxWM0F/PtqKWmdNVesTPTgIjaNFyzV3/7m@9WYKaNjaq1EmZLrlFaS68X2cHUoJ3XYfhoWAJb5XmBARmNf2y7XN3Lm@kB6BlRV77aYfdylwTPYkF0iyfXxLNDP2f2li7GuhRVYO6/tbYBatw8R9xvQQ3T3WYTyhQt0bt@I4BEWBGNmS@9@wJ/QHH5Y42X3/CZ834obxF3gXNBqWt7PpVa@RGRYvmSPqBiXf6wp4GVyuf8JkF2yL6/jXXw "C (clang) ‚Äì Try It Online")
Inputs a pointer to a function \$g\$ (inputting an `int` parameter and returning an `int`), a pointer to an array of positive integers \$L\$, a pointer to an array of \$0\$-base indices \$I\$, and \$I\$'s length \$n\$ (since pointers in C carry no length info).  
Updates \$L\$ in place.
### Explanation
```
f(g(),*L,*I,n)                       // golfed function signature for:  
                                     // int f(
                                     //       int (*g)(int), 
                                     //       int *L, 
                                     //       int *I, 
                                     //       int n  
                                     //      )  
{                                    //  
 for(;n--;)                          // loop over I  
           L[*I  ]=                  // assign L at current index in I
                   g(     );         // to g's return value of  
                     L[*I]           // L at current index in I  
               ++                    // bump I to next index                                                 
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 5 bytes
```
MapAt
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n1aaZ/vfN7HAseR/QFFmXkk0UCBaOc5IQU1HodrQREcBhE2BFAwbALGxjoKljoJxLVBJtSGIBDNNa2tjY/8DAA "Wolfram Language (Mathematica) ‚Äì Try It Online")
Takes input in a slightly annoying format: to apply `f` to `{a,b,c,d,e}` at positions `{1,3,5}` and get `{f[a],b,f[c],d,f[e]}`, we write
```
MapAt[f, {a,b,c,d,e}, {{1},{3},{5}}]
```
Some other varyingly built-in solutions:
* **18 bytes:** `MapAt[#,List/@#2]&`. Takes input `[f,I][L]`. The `{{1},{3},{5}}` syntax bothers me a little, so this lets `I` be an actual list.
* **~~20~~ 19 bytes:** `Map@#~SubsetMap~#2&`. Takes input `[f,I][L]`. `SubsetMap` differs from `MapAt` in that it applies the function to all the elements at some indices at the same time.
* **27 bytes:** `(s=#3;s[[#]]=#2/@s[[#]];s)&`. Takes input `[I,f,L]`. Here, we assign the input to a variable, and manually change the values at positions indexed by `I`.
[Answer]
# [Zsh](https://www.zsh.org/), 36 bytes
```
for x;grep -xq $[++i] f&&F $x||<<<$x
```
[Try it online!](https://tio.run/##qyrO@G@XxlWcWqJgaAJCpgqGEGSgYGisYKlgzOWmoWljY6MSrWKopWUU@z8tv0ihwjq9KLVAQbeiUEElWls7M1YhTU3NTUGloqYGpLTi/39DLmMuEy5TLjMucwA "Zsh ‚Äì Try It Online")
Expects a [function predefined as `F`](https://codegolf.meta.stackexchange.com/a/13707), the operand array as command-line arguments, and the indeces from the file `f`, each on one line.
`for x;`: for each `$x` in the command-line arguments:
* `$[++i]`: increment `$i` (which starts at 0 implicitly)
* `grep -xq f`: check if `$i` is present in the file `f`
	+ `-q`: return success/failure only, don't print matching lines
	+ `-x`: require the whole line to match `$i`. Otherwise `14` would erroneously match `4`
* `&&`: if that succeeds:
	+ `F $x`: call `F` with the argument `$x`
* `||`: else:
	+ `<<<$x`: just print `$x` unaltered
[Answer]
# [Julia](http://julialang.org/), 19 bytes
```
f*L*i=L[i]=f.(L[i])
```
with 1-based indexing
changes `L` itself as the output
[Try it online!](https://tio.run/##hZBNCsIwEIX3OcVshEaDdFJNrZAb9AalgosWIlqlWshS9IDewYvU/DStK11MZhhm5n15h@6o9qj7vp7ncyXzQpWyXkY2076ONAUJesdJbnKBKwY21iaFiE0kDDIGSUmUmzIlAz8mGKQlqVw7E36bmz4fH4ztBZGFE46DXFrV3I5NlNOplLKihASmBXqm1Gxzf1hMANwzDNIbz2h50/8Kr@f7cfcq1@4U6ZmSMob63IKSuNU0IIS5hR7csRLo/uGcEV@BzorVAMidPaZhweLgTzI6iZlf4zisJ8HJ3@z9Bw "Julia 1.0 ‚Äì Try It Online")
[Answer]
# MMIX, 44 bytes (11 instrs)
Takes `f`, `L`, `I`, `len(i)`; both `L` and `I` are lists of `uint64_t`.
`f` is also necessarily MMIXware argument passing.
(jxd -T)
```
00000000: fe040004 3b030303 27030308 8e050203  ‚Äú¬•¬°¬•;¬§¬§¬§'¬§¬§¬Æ‚Åæ¬¶¬£¬§
00000010: 3b050503 8e070105 bf060000 ae060105  ;¬¶¬¶¬§‚Åæ¬¨¬¢¬¶·∏Ç¬©¬°¬°·∫∏¬©¬¢¬¶
00000020: 5b03fffa f6040004 f8000000           [¬§‚Äù¬´·∫á¬•¬°¬•·∫è¬°¬°¬°
```
Disassembly/explanation:
```
foo GET    $4,rJ
    SLU    $3,$3,3
0H  SUBU   $3,$3,8      // loop: leni--
    LDOU   $5,$2,$3     // j = I[leni]
    SLU    $5,$5,3
    LDOU   $7,$1,$5     // a = L[j]
    PUSHGO $6,$0,0      // b = f(a)
    STOU   $6,$1,$5     // L[j] = b
    PBNZ   $3,0B        // iflikely(leni) goto loop
    PUT    rJ,$4
1H  POP    0,0          // return
```
[Answer]
# [Kotlin](https://kotlinlang.org), 48 bytes
```
{f,L,I->L.mapIndexed{i,v->if(i in I)f(v)else v}}
```
[Try it online!](https://tio.run/##hZLBbuIwEIbveYr/UslujYVDNyyocNlTJKo@gwVOZdU1iBjECuXZ2bHdRmmh2khjj8Yz/r9x5m0bnPWXo3Z4nYOx2gc@WtIqsLJteCJvOXDprPexuJwbsRI1xeS73tV@Y05mc7biOFrahllYj5o37MiNaw2OXXfZ6KCxdrpt8Ue3hkXd1XwoFSP1VaQhth6N41wAzcEjmDYwc9qZdTCbQRHHAq@sIXBBBFgs8JlUdEURL1yTejvHs949RZBBi9QXqJuXhpEIMmby4ucoi07Uo0C0X7R92phsIjATmHDxvYAOSzoQyEXVIOOME0ZLWu7JuhTmCNtealZlrZLqyn5R46hXzb4I/gw8peQy31PdpFMZ8BbXA9QNrt@53dj69L/yKVMl1vRW1cAoTNvjNZVKDxbvp8JrMKakPHHZWBfMPgXvYEP812N0cr09@MA4wd981En/s9Qsc5Tqg2eSeKa84EURZ@xdW8/yyAG7vfXBeZbGRxof9pZ27RwBmEhl5Jv5K/NcShq0g@HoeNFd/gE "Kotlin ‚Äì Try It Online")
Very straight-forward algorithm. Uses the [default rule](https://codegolf.stackexchange.com/a/202985/) for submitting lambdas.
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache), 2 bytes
```
On
```
[Try it online!](https://tio.run/##bZBNa8MwDIbv/hWCHetDJXfuMsih0Mtg0N2NB2WbWWBkpUlH9uszfcSjhx7kD1l@30c6juPx7fNj3p1OX7@7ER7b@dDPBdOU@QzTK7nnbhhRLgk3HiTueaux5ggeGg8hu6f@3So5S5zxYNUxu8OlijTRVIgf6H/BtSjFpkq9nLt@TAtWEmEPBXNSmgxtC6KYnStUWVeorKQ2W1YjM4oKRhUMjU2RLPlgPUg/2xvOXF3InKk6kziHxflu3/10w/d5kPsKJsUI1q3oojal44pXwWneNkq3VOvMBIN/KOCVik0ZG/tNuKgEVbnFzS8lGHeo3CHPfw "Attache ‚Äì Try It Online")
There's a Builtin for That‚Ñ¢.
Another builtin solution, 8 bytes: `Over@`->`.
## Without builtins, 22 bytes
*-2 bytes after reading other answers, since this modifies the variable in place. Prepend `;z` before the last `}` to have it also return the value.*
```
${{Set[z,_,y!z@_]}=>x}
```
[Try it online!](https://tio.run/##bZDBSgMxEIbveYpIPSjNoZnU1LWsWPAiCAoeQyzFNrggtXSjbFv67OtkJpEeepiEzEz@@f5ZxLj4@Fz1s83mazeL8q7uLw@Ht1V0ezVXu4v9w9wf6/vu2AftOo912b2DeG7aqNPD6bGSKW7wKjHCMEpWShovntZL7sQsYEZJ7rZevPwUkcqyCmAB/g89Skq2KlKv22Yd3VVmdUlZyYBBOH46pfta1rVM0l6IAAV6qAkaaN4EZYEnWiKEQqgZktg4ectmkrHJOQRsD8AIkBGgIEBCMBlh8Nj8Nu33tk3voeyIx7D/NECTTVqgPQlM4zUmzNxNW0w8@INIT1R477ri36CziiGVswawFAwbMNmAKQaM7/8A "Attache ‚Äì Try It Online")
**23 bytes:** `${z&Set&>Tr![x,z[x]|y]}`
**23 bytes:** `${&@(z&Set)![x,z[x]|y]}`
**31 bytes:** `${{[_,y@_][_2in x]}&>@V#Iota!z}`
**32 bytes:** `${{If[_2in x,y@_,_]}&>@V#Iota!z}`
**33 bytes:** `${{[_,_|y][_2in x]}&>Enumerate@z}`
**33 bytes:** `${{[Id,y][_2]!z@_}#x&Has=>Iota@z}`
**34 bytes:** `${{z@_|If[_2,y,Id]}#x&Has=>Iota@z}`
**34 bytes:** `${{If[x&Has!_2,y@_,_]}&>@V#Iota!z}`
**34 bytes:** `${{[Id,y][x&Has!_2]!_}&>@V#Iota!z}`
[Answer]
# [Elm](https://elm-lang.org/), 62 bytes
```
a f i=List.indexedMap(\n->if List.member n i then f else\x->x)
```
Fairly simple implementation of the function. `List.indexedMap` expects a function which takes 2 `Int`s (in this case), but we can also write a function that takes 1 `Int` and returns an `Int -> Int` function to save ~~3 bytes~~ 1 byte over the more straightforward implementation function `\n e->if List.member n i then f e else e`.
At the cost of 1 byte, the inner function can be written as `List.member>>\h->if h i then f else\x->x`, and the right operand to `>>` *seems* golfable, but I can't quite figure out if that's really the case.
## Test Program
Try it [here](https://elm-lang.org/try)!
```
import Html exposing (text)
a : (Int -> Int) -> List Int -> List Int -> List Int
a f i=List.indexedMap(\n->if List.member n i then f else\x->x)
main =
  a
    (\x -> x ^ 2)
    [0, 2, 3, 4, 5, 6]
    [14, 14, 5, 15, 15, 10, 13, 9, 3]
  |> List.map String.fromInt
  |> String.join ", "
  |> (\x -> "[" ++ x ++ "]")
  |> text
```
]