Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16913
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Chained-functional notation examples? |
| Date | 2014-05-07 06:44 +0000 |
| Message-ID | <lkckot$hb9$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
On 5/6/14 at 2:26 AM, dog@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.
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Re: Chained-functional notation examples? Bill Rowe <readnews@sbcglobal.net> - 2014-05-07 06:44 +0000
csiph-web