I've a list of lists like
list = {
{a, b, c, d},
{e, f, g, h},
{i, j, k, l}
}
and would like to apply a function y
to the middle two elements from the list, so the output should be:
{
{a, y[b, c], d},
{e, y[f, g], h},
{i, y[j, k], l}
}
My current approach is doing
Map[{#[[1]], y[#[[2]], #[[3]]], #[[4]]} &, list]
However, the actual lists are long so I'd like to avoid typing out #[[1]]
, #[[4]]
etc. (all elements left unchanged). How can I do this?
I tried MapAt but couldn't make it work.
m×2n
list? $\endgroup$