Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: Functional programming puzzle

  • To: mathgroup at
  • Subject: [mg1861] Re: [mg1821] Functional programming puzzle
  • From: Allan Hayes <hay%haystack at>
  • Date: Wed, 9 Aug 1995 22:38:06 -0400

"Wm. Martin McClain" <wmm at>
wrote in [mg1821] Functional programming puzzle
Dear functional programers:

> Let ptList = {{1,1,2},{2,1,3},{1,3,2}};
> I want a matrix of distances between the points in ptList.
> Any human would think you could get it with
> Rij[a_,b_]:=Sqrt[(a-b).(a-b)]
> followed by
> Outer[Rij,ptList,ptList]
> But Mathematica returns a mess, because Outer seems
> to Flatten the ptList before running the outer
> product loops.
> ...................


Outer has an optional, and apparently undocumented, final parameter  
for setting the level at which it operates. Hence:

ptList = {{1,1,2},{2,1,3},{1,3,2}};



	0         Sqrt[2]   2

	Sqrt[2]   0         Sqrt[6]

	2         Sqrt[6]   0

Allan Hayes
De Montfort University Leicester
hay at

  • Prev by Date: Axis direction
  • Next by Date: Re: Math co-processor
  • Previous by thread: Re: Functional programming puzzle
  • Next by thread: Re: Functional programming puzzle