f



Chained-functional notation examples?

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.

A major benefit of functional [unix-piping] programming style, is that you
don't need to remember the-full-journey: you just need to remember the previous stage's output. Nor do you need to remember several names: the previous output is just "it".  A superficial read through a recent article[s] here, about <collecting data from several servers, and agregating it, and sending the result to a master> seemed very interesting, and matches my ideas of using functional programming.  But I can't afford to invest in ANOTHER notation/syntax, without good prospect of productivety increase.

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 .

Actually, this seems not a good example, since it's biased towards the *nix
file system's format/syntax.

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]

This sounds like a data-base problem?

Or is there a nice list of 'such' Mathematica examples?

 Thanks,

== John Grant.

0
Unknown
5/6/2014 6:26:46 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

2 Replies
581 Views

Similar Articles

[PageSpeed] 17

On Tue, 06 May 2014 06:26:46 +0000, 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.
> 
> A major benefit of functional [unix-piping] programming style, is that
> you don't need to remember the-full-journey: you just need to remember
> the previous stage's output. Nor do you need to remember several names:
> the previous output is just "it".  A superficial read through a recent
> article[s] here, about <collecting data from several servers, and
> agregating it, and sending the result to a master> seemed very
> interesting, and matches my ideas of using functional programming.  But
> I can't afford to invest in ANOTHER notation/syntax, without good
> prospect of productivety increase.
> 
> 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 .
> 
> Actually, this seems not a good example, since it's biased towards the
> *nix file system's format/syntax.
> 
> 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]
> 
> This sounds like a data-base problem?
> 
> Or is there a nice list of 'such' Mathematica examples?
> 
>  Thanks,
> 
> == John Grant.

Here's a related real-live problem:
 list all files in Dir-tree:D |
 which are less-than daysOld:N |
 and contain "egal" in the FullPathName |
  and contain String:"uid" OR "UID"

0
Unknown
5/7/2014 6:45:05 AM
Am Dienstag, 6. Mai 2014 08:26:46 UTC+2 schrieb Unknown:
> 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.
>
>
>
> A major benefit of functional [unix-piping] programming style, is that you
>
> don't need to remember the-full-journey: you just need to remember the previous stage's output. Nor do you need to remember several names: the previous output is just "it".  A superficial read through a recent article[s] here, about <collecting data from several servers, and agregating it, and sending the result to a master> seemed very interesting, and matches my ideas of using functional programming.  But I can't afford to invest in ANOTHER notation/syntax, without good prospect of productivety increase.
>
>
>
> 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 .
>
>
>
> Actually, this seems not a good example, since it's biased towards the *nix
>
> file system's format/syntax.
>
>
>
> 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]
>
>
>
> This sounds like a data-base problem?
>
>
>
> Or is there a nice list of 'such' Mathematica examples?
>
>
>
>  Thanks,
>
>
>
> == John Grant.


Well, I think that postfixing by use of the Mathematica Postfix operator "//"
accompanied by use of Mathematica pure Function "&" with access to the last result =
by using Mathematica Slot "#" (argument to the pure Function)
mimics *nix piping best:

the following gets all files of "c:/temp" in all sub dirs
older than 200 days
containing at least one of the strings "str1", "str2" :


"c:/temp" //
FileNames["*", #, Infinity]& //
Select[#, DateDifference[FileDate[#], DateList[]] > 200 &]& //
Select[#, StringMatchQ[#, "*str1*"] || StringMatchQ[#, "*str2*"]&] &

Regards Robert

0
roby
5/9/2014 6:06:05 AM
Reply:

Similar Artilces:

Re: Chained-functional notation examples?
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 dif...

Re: Chained-functional notation examples? #3
A query such as this might do what you have in mind. Here directoryname should be changed to whatever directory you want searched. Select[FileNames[("*uid*" | "*UID*"), directoryname, Infinity], ((StringMatchQ[DirectoryName[#] , "*egal*"] && Today < DayPlus[FileDate[#], 3]) &] Also there is a case sensitive switch if you want to allow strings with e.g. "uID". If you want to allow that uid only in the name and not full string Daniel Lichtblau Wolfram Research ------------------- On Tue, 06 May 2014 06:26:46 +0...

Re: Chained-functional notation examples? #2
A query such as this might do what you have in mind. Here directoryname should be changed to whatever directory you want searched. Select[FileNames[("*uid*" | "*UID*"), directoryname, Infinity], ((StringMatchQ[DirectoryName[#] , "*egal*"] && Today < DayPlus[FileDate[#], 3]) &] Also there is a case sensitive switch if you want to allow strings with e.g. "uID". If you want to allow that uid only in the name and not full string Daniel Lichtblau Wolfram Research ------------------- On Tue, 06 May 2014 06:26:46 +0...

Re: Chained-functional notation examples? #4
A query such as this might do what you have in mind. Here directoryname should be changed to whatever directory you want searched. Select[FileNames[("*uid*" | "*UID*"), directoryname, Infinity], ((StringMatchQ[DirectoryName[#] , "*egal*"] && Today < DayPlus[FileDate[#], 3]) &] Also there is a case sensitive switch if you want to allow strings with e.g. "uID". If you want to allow that uid only in the name and not full string Daniel Lichtblau Wolfram Research ------------------- On Tue, 06 May 2014 06:26:46 +0...

Re: Chained-functional notation examples? #5
On 5/7/14 at 2:44 AM, dog@gmail.com (Unknown) wrote: >Here's a related real-live problem: >list all files in Dir-tree:D | which are less-than daysOld:N | and >contain "egal" in the FullPathName | and contain String:"uid" OR >"UID" It is not entirely clear what it is you are trying to do. There are a couple of ways to obtain a list of files in a given directory. First, if the directory is the current working directory, then FileName[] will return a list of every thing at the top level of the directory. But in this case, only the...

interactive web Mathematica examples on Math World not working under firefox?
hello, When I try any of the new interactive examples on MathWorld, they do not work when I am using FireFox (i am running 1.0.6 on windows). for example this one http://mathworld.wolfram.com/LogGammaFunction.html But they work with IE. I went through the registration process using both browsers. I get the email, and click on the link in the email, but still it does not work in firefox. Has any one got these to work under firefox browser? Does the registration to use these interactive examples needs to be done for each browser? (I do not like this idea that one ...

Using 2D Math notations with underscores as in x_1 is not supported by Maple functions??
Please tell me I am doing something wrong here. One of the advantages in the new interface is to be able to write mathematical variables close to the way we do on paper. So I wrote something using x_1, x_2, etc.... as opposed to x[1], x[2] etc... I did this by typing 'x' then SHIFT UNDERSCORE, then typed '1' , etc.... All is ok. But it seems when I called this particular Maple function in LinearAlgebra, passing it the list of variables and equations written this way, the function gave me an error about unable to split rhs for multiple assignment. But ...

Executing function in mathematica function problem
Hello, I've created simple procedure in another system, which takes one parameter (x(1)) as argument function and returns one value. After compilation, with 'mex -l fnc.m' command I've created a shared library. In Mathematica's script I load this function with: link = Install["f:\\f1.exe"]; F1[0.5] # I have a correct result Then I define such argument, which are part of a function fCE=F1[x1]; f C[{x1_}]=fCE; and execute the Mathematica function FNC[...,fC,...]. The FNC is defined as follow FNC[...,fC_,...]:=Block[{..., fCi,...,cog,} ..... bv...

Novice problem in mathematica syntax : Function of a function:
hi, What I want to do is to : Plot Reflectivity: Refelectivity is an expression ( or a function ) depending on nfilm which in turn depends on epsmodel( which in itself is a function of 3 parameters and a variable ) therefore : epsmodel = f(a,b,c,d,x) (* result is a comlpex number *) nfilm = sqrt[epsmodel] reflectivity = ((nfilm - 1) / (nfilm +1))^2 I just want to plot reflectivity and see the variation in it when (a,b,c,x) varies ( using the Manipulate[] tool ) Please let me know how to do this in term of these functions ? the exact formalism for which I got the err...

Mathematica- Use a previous equation into the function Function
Dear All, I am fairly new to mathematica. I am stuck with a problem I cannot solve. I would like to call a previous equation into the function Function. If a type directly the expression or copy paste it, it works. However, when I call the expression by its name it does not. Here is the code for a more precise explanation: In: ll Out: d + a x + h x^2 + b y + e x y + c z + j z^2 In: Function[##, a x + b y + c z + d + e x y + h x^2 + j z^2] & @@ {Listp} Out: Function[{a, b, c, d, e, h, j}, a x + b y + c z + d + e x y + h x^2 + j z^2] It works well and I can use it to genera...

Re: Mathematica- Use a previous equation into the function Function
On 8/1/10 at 4:58 AM, camille.segarra@gmail.com (Camille) wrote: >I am fairly new to mathematica. I am stuck with a problem I cannot >solve. I would like to call a previous equation into the function >Function. If a type directly the expression or copy paste it, it >works. However, when I call the expression by its name it does not. >Here is the code for a more precise explanation: > >In: ll Out: d + a x + h x^2 + b y + e x y + c z + j z^2 >In: Function[##, a x + b y + c z + d + e x y + h x^2 + j z^2] & @@ >{Listp} Out: Function[{a, b, c, d, e, h, ...

How to call Mathematica Boolean functions from non-Mathematica apps
Hi, In Wolfram Workbench, I'm running a Java app that's working ok with the generic import import com.wolfram.jlink.*; , and it will execute basic functionality like evaluate, getInteger, etc. But I can't seem to execute any of Mathematica's Boolean functions. Can't use BooleanConvert, nor BooleanFunction, nor BooleanMinimize, or any of the related methods. Does anyone know how to access these? I'm using createKernelLink(). ...

Fyi, Listing of Mathematica 7 functions (1869 functions)
I've update my Mathematica history table with a new listing of Mathematica 7 functions (not just the symbols). These are anything in Mathematica System context which has the form name[...] I want to thank John Fultz for his hint in another posting in this newsgroup to use the Usage message from ? and look for anything that starts with this pattern. I obtain 1869 functions. Since what I find is somewhat less what it is supposed to be (close to 2,500) according to WRI blog here http://blog.wolfram.com/2008/11/18/surprise-mathematica-70-released-today/ I could only sug...

Re: Novice problem in mathematica syntax : Function of a function
hi, What I want to do is to : Plot Reflectivity: Refelectivity is an expression ( or a function ) depending on nfilm which in turn depends on epsmodel( which in itself is a function of 3 parameters and a variable ) therefore : epsmodel = f(a,b,c,d,x) (* result is a comlpex number *) nfilm = sqrt[epsmodel] reflectivity = ((nfilm - 1) / (nfilm +1))^2 I just want to plot reflectivity and see the variation in it when (a,b,c,x) varies ( using the Manipulate[] tool ) Please let me know how to do this in term of these functions ? the exact formalism for which I got the error : ...

Web resources about - Chained-functional notation examples? - comp.soft-sys.math.mathematica

Resources last updated: 1/26/2016 11:21:04 PM