MathGroup Archive 2006

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

Search the Archive

Re: position lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68737] Re: position lists
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 17 Aug 2006 04:18:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 8/16/06 at 3:36 AM, rychphd at gmail.com (rych) wrote:

>have
>  In: a = {1, 1, 2, 2, 1, 4}
>want
>  {{1, 2, 5}, {3, 4}, {0}, {6}};

>more effectively than just
>  In: Position[a, #] & /@ Range[4]
>  Out: {{{1}, {2}, {5}}, {{3}, {4}}, {}, {{6}}}

>Ideas? Known one-liners?

Other than

In[4]:=
(Flatten[Position[a, #1]] & ) /@ Range[4] /. {} -> {0}

Out[4]=
{{1,2,5},{3,4},{0},{6}}

no
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: position lists
  • Next by Date: calculate Recurrence Equations
  • Previous by thread: Re: position lists
  • Next by thread: Re: position lists