MathGroup Archive 2014

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

Search the Archive

Re: Chained-functional notation examples?

  • To: mathgroup at
  • Subject: [mg132695] Re: Chained-functional notation examples?
  • From: Bill Rowe <readnews at>
  • Date: Wed, 7 May 2014 02:44:23 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

On 5/6/14 at 2:26 AM, dog at (Unknown) wrote:

>I came to 'Mathematica' via Xahlee's criticism of the ad-hoc nature
>of unix-piping [functional notation].  He claims [& I believe him]
>that Mathematica has a better, more consistent notation.  But the
>facility of PRE, IN & POST-fix alternatives, seems bad.  You want
>ONE way of acieving the goal. More rules just increases mental load.

If you are looking for a system with one way to achieve a given
goal, Mathematica isn't it. There are multiple ways of achieving
a result without using different notations. For example,
consider how you might find the sum of the first n integers. All
of the following will work:

limit = 10^6;
For[sum = 0; n = 1, n <= 10, n++, sum += n]; sum




Intelligent use of pre-, post- and in-fix notations generally
makes Mathematica code easier to read/understand. For example, I
could have written

Total[Range@limit] as


but fewer levels of [] makes it easier from my perspective to read.

>Just as a test, how would Mathematica handle the following [or part
>of] little task:

>search all files in Dir=tree D |
>which are less than N days-old | and which contain string S1 | and
>which contain string S2 .

   (FileType[#]===File &&
    StringCases[#, s1]!={} &&
    StringCases[#, s2]!={} &&
    (Subtract@@(AbsoluteTime /@ {Date[][[;; 3]], FileDate[#][[;; 3]]}/86400)<age)&]

No need to pipe results from one operation to the next. And the
above syntax is platform neutral.

>Try: Search in table of ListOfOpenFiles for lineS with path-P
>[field] | which have same tty-field as line with path-P2 & program-M [field]

Less clear here to me what it is you are looking for, but
FindList is probably the right function.

  • Prev by Date: Installing Mathematica on redhat "Extras" fails
  • Next by Date: Re: Chained-functional notation examples?
  • Previous by thread: Chained-functional notation examples?
  • Next by thread: Re: Chained-functional notation examples?