Why is it that
f[{{a_, b_}, {c_, d_}}] := (a z + b)/(c z + d)
will return (2 + z)/(4 + 3 z)
on evaluating f[{{1, 2}, {3, 4}}]
while
g = Function[{{a, b}, {c, d}}, (a z + b)/(c z + d)]
will return Function[{{a, b}, {c, d}}, (a z + b)/(c z + d)][{{1, 2}, {3, 4}}]
on evaluating g[{{1, 2}, {3, 4}}]
?
Is there a nice way to get the behavior of f
rather than g
while still giving Mathematica input that "looks" like g
?
I'd like to have the ability to write a function that visually looks nearly identical to $$\left(\begin{array}{cc}a & b \\ c & d\end{array}\right) \mapsto \frac{a z + b}{c z + d}$$
using the $\mapsto$ pure function definition available by typing [esc]fn[esc]
into the notebook interface. But because Function
seems to behave differently from the definition of functinos via SetDelayed I'm having a hard time with this.
To be explicit (since this is a matter of what the interface looks like, which can't be replicated in the markdown here), I'd like to be able to enter input that looks like this:
while behaving like f
as I've defined above.