dpaukov / combinatoricslib3

Combinatorial objects stream generators for Java.
Apache License 2.0
177 stars 24 forks source link

One more example on K-Permutation #9

Closed fengertao closed 3 years ago

fengertao commented 3 years ago

Original k-permutation example print output into console. while cannot collect result into a collection for further processing.

        Generator.combination("1", "2", "3", "4")
                .simple(2)
                .stream()
                .forEach(combination -> Generator.permutation(combination)
                        .simple()
                        .stream()
                        .forEach(System.out::println))

Below example collect result into a collection for further processing

        List<List<String>> kPermutationResult = Generator.combination("1", "2", "3", "4")
                .simple(2)
                .stream()
                .flatMap(combination -> Generator.permutation(combination)
                        .simple()
                        .stream()
                        )
                .collect(Collectors.toList());
fengertao commented 3 years ago

Cancel this issue, for new k-permutation API provided reason