Search This Blog

Saturday, September 11, 2010

How do I get all the possible combinations of neighboring items in a subsequent order using Perl?

Programmer Question

For example, I have an array



my @arr = qw(0 1 2 3 4);


How do I get the following combinations:



0
01
012
0123
01234
1
12
123
1234
2
23
234
3
34
4


If any, what's the name for this kind of combination (or permutation)?



Thanks like always!



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails