| 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: , |
|