MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Distance between to points in r^3

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41660] Re: Distance between to points in r^3
  • From: Olaf Rogalsky <Olaf.Rogalsky at physik.uni-erlangen.de>
  • Date: Thu, 29 May 2003 08:15:41 -0400 (EDT)
  • Organization: University of Erlangen, Germany
  • References: <bauv0f$m7$1@smc.vnet.net> <bavavj$2bb$1@smc.vnet.net> <bb1uro$9ft$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jeremy Foster wrote:
> Could you explain the syntax #.# and &[p1-p2]? I don't recognize this. Thanks.

<expr>& denotes an unnamed function. The formal parameters of that function are 
available through "#1", "#2", ..., "#n" inside of <expr>. "#" is a synonym for 
"#1". As usual, the actual parameters in a call to that function are denoted
by square brackets immediately following the function.

The following lines are (mostly) equivalent:

f[x_]:=Sqrt[x]; f[25]
f=Sqrt[#]&; f[25]
f=Sqrt[#1]&; f[25]
(Sqrt[#]&)[25]
Sqrt[25]

Unnamed functions are usefull in many contexts, e.g. in Map[]:
ListPlot[Map[{#,#^2}&,Range[-100,100]]]


-- 
+----------------------------------------------------------------------+
I Dr. Olaf Rogalsky                         Institut f. Theo. Physik I I
I Tel.: 09131 8528440                       Univ. Erlangen-Nuernberg   I
I Fax.: 09131 8528444                       Staudtstrasse 7 B3         I
I rogalsky at theorie1.physik.uni-erlangen.de  D-91058 Erlangen           I
+----------------------------------------------------------------------+


  • Prev by Date: RE: Matrix inverse not evaluating
  • Next by Date: Width limited matrix printer
  • Previous by thread: RE: Distance between to points in r^3
  • Next by thread: question on big-O-notation