Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: position lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68718] Re: [mg68688] position lists
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Thu, 17 Aug 2006 04:18:26 -0400 (EDT)
  • References: <200608160736.DAA06180@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Aug 16, 2006, at 3:36 AM, 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?

Flatten[Position[a,#]]&/@Range[4]/.{}->{0}

Regards,

Ssezi


  • Prev by Date: Several functions in a single 2D-plot
  • Next by Date: Re: position lists
  • Previous by thread: position lists
  • Next by thread: Re: position lists