Thanks a lot. However, it seems like it misses the last iteration (but that is easily fixed):
< } 0 .. $#_ - $min; --- > } 0 .. $#_ - $min + 1;
$ perl -wl use strict; use Test::More tests => 3; use Test::Deep; sub adjSets{ my $min = shift; map { my $start = $_; map { [ @_[ $start .. $start+$_ ] ] } $min-1 .. $#_-$start; } 0 .. $#_ - $min + 1; # <-- one more iteration } my @arr1 = adjSets(2, qw(one two three)); cmp_deeply(\@arr1, [ [ 'one', 'two' ], [ 'one', 'two', 'three' ], [ 'two', 'three' ] ], q{Test 1}); my @arr2 = adjSets(3, qw(one two three four five)); cmp_deeply( \@arr2, [ [ 'one', 'two', 'three' ], [ 'one', 'two', 'three', 'four' ], [ 'one', 'two', 'three', 'four', 'five' ], [ 'two', 'three', 'four' ], [ 'two', 'three', 'four', 'five' ], [ 'three', 'four', 'five' ], ], q{Test 2} ); my @arr3 = adjSets(4, qw(one two three four five six)); cmp_deeply( \@arr3, [ [ 'one', 'two', 'three', 'four' ], [ 'one', 'two', 'three', 'four', 'five' ], [ 'one', 'two', 'three', 'four', 'five', 'six' ], [ 'two', 'three', 'four', 'five' ], [ 'two', 'three', 'four', 'five', 'six' ], [ 'three', 'four', 'five', 'six' ], ], q{Test 2} ); __END__ 1..3 ok 1 - Test 1 ok 2 - Test 2 ok 3 - Test 2 $
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Re^2: Subsets and adjacent values by andreas1234567
in thread Subsets and adjacent values by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.