Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2008

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

Search the Archive

Re: Functional programming?

  • To: mathgroup at
  • Subject: [mg91975] Re: [mg91945] Functional programming?
  • From: Murray Eisenberg <murray at>
  • Date: Mon, 15 Sep 2008 03:43:20 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <>
  • Reply-to: murray at

Here's my favorite very simple example, for instructional purposes, that 
employs some functional programming -- hardly "real-world", I suspect, 
in the sense you mean.  It's not "pure" functional programming, in that 
some arguments are explicitly mentioned in definitions, but it does 
includes some functional programming.

   newtonStep::usage="newtonStep[{c, x0}] performs one step of Hero's 
method to find a better estimate x1 for the square-root of c given 
estimate x0; the result has the form {c, x1}";

   newton::usage="newton[c, epsilon, x0] applies Hero's method to find 
the square-root of c with |error| < epsilon, given the initial estimate 

   newtonStep[{c_, x_}] := {c,Mean[{x,c/x}]}


   newton[2, 10.^-13, 1.] // NumberForm[#, 12] &

I leave to explicit-looping advocates the exercise of coding the same 
thing in a Do or other explicit loop.

Note that I consider array-oriented programming, such as originated in 
APL and as derivatively and partially incorporated into Mathematica, as 
a somewhat different programming paradigm from functional programming.

AES wrote:
> I suggest it might be instructive if some of the functional programming 
> proponents on this group could provide us DO-looping old timers with a 
> brief summary or tutorial as to what is really meant by, or involved in, 
> "functional programming"? 
> --- especially as this concept might relate to building programs to do 
> calculations involving multi-stage real-world engineering or technical 
> problems 
> --- and especially as it might relate to programs that are going to be 
> developed in an evolutionary process and that in the end, rather than 
> being built into some long-term library, are maybe only going to be run 
> or executed a few times before the person involved (e.g., an engineer, 
> or scientist, or other real-world individual, not a "programmer") moves 
> on to some other totally different task or assignment.

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Functional programming?
  • Next by Date: Re: Regressions in Mathematica
  • Previous by thread: Re: Functional programming?
  • Next by thread: Re: Functional programming?