# Why is a function just repeating input [closed]

This should give the answer of 2, but all it does is repeat the input. What is wrong?

dist[P_, Q_] := Sqrt[(P[[1]] - Q[[1]])^2 + (P[[2]] - Q[[2]])^2]
dist[2, 3, 2, 1]

(* Out: dist[2, 3, 2, 1] *)

• dist is only defined to take two arguments, so when you give it four it remains undefined. Try dist[{2, 3}, {2, 1}] instead. – Chris K Jan 3 at 20:37

## 1 Answer

Please try

Norm[{2, 3} - {2, 1}]


this results in 2.

Please note: Wolfram Language has an enormous amount of prebuild functions which are available.

You can also use

dist[{2, 3}, {2, 1}]


Hope this helps.

• Thanks. Norm worked but my dist still didn't with the braces as above. I copied that exactly from a professor's notes, but maybe he got it wrong. I'll just write my own for practice. BTW, can I include notes with a function that will show up in screen help, as you can in Python? – cybervigilante Jan 3 at 20:53
• Found out how to put in comments, but alas, they don't show up in popup help. – cybervigilante Jan 3 at 21:00