MathGroup Archive 2006

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

Search the Archive

Re: position lists


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?
> Thanks
> Igor
> 
Hi Igor,

I am not sure whether this might be what you are looking for,

(Flatten[Position[a, #1]] & ) /@ Range[4]

--> {{1, 2, 5}, {3, 4}, {}, {6}}

HTH,
Jean-Marc


  • Prev by Date: Complexity of quantifier elimination
  • Next by Date: RE: position lists
  • Previous by thread: Re: position lists
  • Next by thread: RE: position lists