Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: List of position-specifying functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102370] Re: [mg102351] List of position-specifying functions
  • From: "Elton Kurt TeKolste" <tekolste at fastmail.us>
  • Date: Fri, 7 Aug 2009 05:29:24 -0400 (EDT)
  • References: <200908061032.GAA01790@smc.vnet.net>

Ray

Is this what you had in mind?

In[9]:= positionFunctionApplication[function_, fullArgumentList_, 
  subsetOfIndices_] := 
 Map[function, fullArgumentList[[subsetOfIndices]]]

In[10]:= positionFunctionApplication[f, {a, b, c, d, e}, {1, 3, 5}]

Out[10]= {f[a], f[c], f[e]}


Kurt

On Thu, 06 Aug 2009 06:32 -0400, "Ray Koopman" <koopman at sfu.ca> wrote:
> I have a list of distinct positive integers, such as
> 
> In[1]:= plist = {2, 5, 4, 6, 3};
> 
> I want to convert it to a list of position-specifying functions,
> such as might be used as the second argument in SplitBy or GatherBy.
> One way that works is:
> 
> In[2]:= plist /. p_Integer->(#[[p]]&)
> 
> Out[2]= { #1[[2]]&, #1[[5]]&, #1[[4]]&, #1[[6]]&, #1[[3]]& }
> 
> I've been trying to get the same thing using Map,
> but I haven't been able to do it. Any suggestions?
> 
Regards,
Kurt Tekolste



  • Prev by Date: Re: List of position-specifying functions
  • Next by Date: Re: Manipulate
  • Previous by thread: Re: List of position-specifying functions
  • Next by thread: Re: List of position-specifying functions