#
# This software is Copyright 2005 by Elsevier Inc.  You may use it
# under the terms of the license at http://perl.plover.com/hop/LICENSE.txt .
#



###
### flatten-imap
###

## Chapter 5 section 1.1.1

my $which_partition_iterator = 0;
flatten( Iterator  {
  $which_partition_iterator++;
  if ($which_partition_iterator == 1) {
    return imap {[$first, @$_]} partition($target-$first, \@rest);
  } elsif ($which_partition_iterator == 2) {
    return                      partition($target,        \@rest);
  } else {
    return;
  }
});
