[Date Index]
[Thread Index]
[Author Index]
Re: Chained-functional notation examples?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg132695] Re: Chained-functional notation examples?
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Wed, 7 May 2014 02:44:23 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-outx@smc.vnet.net
*Delivered-to*: mathgroup-newsendx@smc.vnet.net
On 5/6/14 at 2:26 AM, dog at gmail.com (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
Plus@@Range[limit]
Total[Range@limit]
Sum[n,{n,m}]/.m->limit
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
Total[Range[limit]]
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 .
SetDirectory[dirname];
Cases[FileNames[],
(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?**
| |