Skip to main content
1 of 2
Alan
  • 13.8k
  • 21
  • 41

Use With instead of Module?

ClearAll[a, b, c, d, pick, ex, co]

ExpandPick[exp_] := With[{
   p = FirstPosition[exp, _pick]
   }, With[{
    x = First@Extract[exp, p],
    y = Last@Extract[exp, p]
    },
   ReplacePart[exp, p :> ex[Function[co, {co[x], co[y]}]]]]]
Alan
  • 13.8k
  • 21
  • 41