Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Partitioning a List' topicStudent Support Forum > General > Archives > "Partitioning a List"

Next Comment >Help | Reply To Topic
Author Comment/Response
Afshin
01/26/09 10:49pm

How can one partition a list based on a given pattern?

For example if I have the following list:

{a,a,a,b,b,c,c,c}

and i need to partition this in {a,b} - to pair one 'a' and one 'b' as many times as possible within the list so the result is:

{a,{a,b},{a,b},c,c,c}

Basically i need to know how many accurances of {a,b} exist in the list, even a number saying (2) in this case works great. There are two accurance of tuple {a,b} in this list.

Any suggestions on how one might approach this problem?


Thanks,
Afshin

PS. 'Tally' function might come handy, but i couldn't really utilize it.


URL: ,

Subject (listing for 'Partitioning a List')
Author Date Posted
Partitioning a List Afshin 01/26/09 10:49pm
Re: Partitioning a List Kaveh 01/27/09 9:53pm
Next Comment >Help | Reply To Topic