Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11347


Ignore:
Timestamp:
09/05/14 22:25:15 (10 years ago)
Author:
bburlacu
Message:

#2220: Fixed bug in the CartesianProduct extension method that was added in r11309 as part of #2234.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/EnumerableExtensions.cs

    r11309 r11347  
    9696    public static IEnumerable<IEnumerable<T>> CartesianProduct<T>(this IEnumerable<IEnumerable<T>> sequences) {
    9797      IEnumerable<IEnumerable<T>> result = new[] { Enumerable.Empty<T>() };
    98       return sequences.Aggregate(result, (current, s) => (from seq in current from item in s select seq.Concat(new[] { item })));
     98      return sequences.Where(s => s.Any()).Aggregate(result, (current, s) => (from seq in current from item in s select seq.Concat(new[] { item })));
    9999    }
    100100  }
Note: See TracChangeset for help on using the changeset viewer.