MathGroup Archive 2009

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

Search the Archive

Re: Using Select

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97489] Re: Using Select
  • From: "Karsten W." <Karsten.G.Weinert at googlemail.com>
  • Date: Sat, 14 Mar 2009 05:38:23 -0500 (EST)
  • References: <gpacsh$ms3$1@smc.vnet.net> <gpdag1$ju8$1@smc.vnet.net>

Thanks a lot for your suggestions! I learned a lot from them (_?
Positive -- n_/; n>0 -- /@)

Kind regards,
Karsten.

On 13 Mrz., 10:54, Szabolcs Horv=E1t <szhor... at gmail.com> wrote:
> Karsten W. wrote:
> > Hello,
>
> > here is a problem I have solved but I am not happy with the method
>
> > I have a data matrix DATA, a list of m ordered n-tuples. I run a
> > function on the data matrix which returns a list DATAEVAL with m
> > elements. The i-th element of this list corresponds to the i-th tuple
> > of the data matrix. I think of this DATAEVAL list as an additional
> > column of the data matrix.
>
> > Now I am only interested in those tuples of the data matrix, where the
> > corresponding DATAEVAL list has a value greater than zero.
>
> > My current approach is the following: I add the DATAEVAL list to the
> > data matrix and call Select afterwards:
>
> > data = Import[...];
> > dataEval = f[data, ...];
> > filteredData = Select[Transpose[Join[Transpose[data], {dataEval}] ],
> > Last[#] > 0 &];
>
> > This works. However, calling Transpose two times seems not to be the
> > most efficient way to solve the problem.
>
> > As a newbie to Mathematica (and functional programming), I wonder if
> > you can point me to a simpler solution?
>
> Hello Karsten,
>
> Use Pick[].
>
> Pick[DATA, DATAEVAL, n_ /; n > 0]



  • Prev by Date: Re: Notebook that auto-executes when opened?
  • Next by Date: Re: ListPointPlot3D not composable?
  • Previous by thread: Re: Using Select
  • Next by thread: Notebooks that auto-execute when opened? -- SOLVED (I think)