# Operate over list of pure functions

I have list of pure functions (All functions are InterpolatingFunction) i.e

{{a, b}, {c, d}, {e, f}, ...}


and I would like to end up with

{ (a[#]/b[#])&, (c[#]/d[#])&,(e[#]/f[#])&,...}


the closest I have got is to do

(Divide @@ Through[#[x]]) & /@ {{a, b}, {c, d}, {e, f}}

{a[x]/b[x], c[x]/d[x], e[x]/f[x]}


but these are not pure functions.

## 3 Answers

This perhaps:

Function[{a, b}, a[#]/b[#] &] @@@ {{a, b}, {c, d}, {e, f}}
(* Out: {a[#1]/b[#1] &, c[#1]/d[#1] &, e[#1]/f[#1] &} *)


Mr.Wizard's way of writing it (see comment) looks like this in the frontend: • Can also be written: ({x, y} \[Function] x[#]/y[#] &) @@@ {{a, b}, {c, d}, {e, f}} – Mr.Wizard Oct 21 '14 at 17:23
• @Mr.Wizard Thanks, I hadn't seen \[Function] before! I added an image to the answer so everyone can see how it looks there. – C. E. Oct 21 '14 at 17:34

You can almost always turn to replacement patterns when you need to transform expressions:

Cases[
{{a, b}, {c, d}, {e, f}},
{x_, y_} :> (x[#]/y[#] &)
]

{a[#1]/b[#1] &, c[#1]/d[#1] &, e[#1]/f[#1] &}


Cases defaults to levelspec {1} so this is safer than using /..

Also:

With[{a = #1, b = #2}, a[#]/b[#] &] & @@@ {{a, b}, {c, d}, {e, f}}


or

x[#]/y[#] & /. {x -> #1, y -> #2} & @@@ {{a, b}, {c, d}, {e, f}}

(* {a[#1]/b[#1] &, c[#1]/d[#1] &, e[#1]/f[#1] &} *)