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

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Aaron Honecker
10/31/00 1:27pm

>OK, having a list of the form {a,b,c,d...}, how do I make this into the form {{a,b},{b,b},{b,c},{c,c},{c,d},{d,d}...}? Thanks

Here's one way

A = {a, b, c, d};
ReplaceList[A, {___, $x_, $y_, ___} -> Sequence[{$x, $y}, {$y, $y}]]

produces

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


URL: ,

Subject (listing for 'List partitioning')
Author Date Posted
List partitioning Jakob Björnb... 10/31/00 07:59am
Re: List partitioning Aaron Honecker 10/31/00 1:27pm
< Previous CommentHelp | Reply To Comment | Reply To Topic