Pipes within Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg18123] Pipes within Mathematica?
- From: simon shannon <sshannon at taz.dra.hmg.gb>
- Date: Fri, 18 Jun 1999 00:51:34 -0400
- Organization: dera
- Sender: owner-wri-mathgroup at wolfram.com
dear all, does anyone know of an easy way of piping within a Mathematica session? say i have an arbitrary list of data like this: data = {"slap", "boink", 4, 5.3, Pi}; and some procedures which each take a list as input, do something sequentially to the input proc1[x_] := Hash /@ x proc2[x_] := Split[x, Xor[EvenQ[#1],OddQ[#2]]&] proc3[x_] := Scan[Print[Length[#]]&, x] note that proc2 doesn't just apply an operation to each single element---depending on the input we get an arbitrary partitioning of its input (depending on the test we give to Split[]). so my question is: rather than doing proc3[proc2[proc1[data]]] which generates the entire result list for proc1 before handing on to proc2, and similarly for proc3, is there a way of doing what in unix parlance might be written proc1 < data | proc2 | proc3 or, indeed, if data were itself a generating process an even simpler data | proc1 | proc2 | proc3 there are languages that allow procedures to voluntarily relinquish control to other processes using suspend() and resume() type statements; perhaps something like this is possible using the Catch[] and Throw[] in Mathematica. thanks in advance simon shannon
- Follow-Ups:
- Re: Pipes within Mathematica?
- From: Jay Gallivan <jay_gallivan@PaineWebber.COM>
- Re: Pipes within Mathematica?