lambda 生成笛卡尔集

Posted 叮咚_打地鼠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lambda 生成笛卡尔集相关的知识,希望对你有一定的参考价值。

public static void getDiKaEr() {
    List<List<String>> source = new ArrayList<>();
 List<String> color = Arrays.asList("红色", "白色", "蓝色");
 List<String> size = Arrays.asList("中", "大", "小");
 List<String> origins = Arrays.asList("中国", "瑞士");
 source.add(color);
 source.add(size);
 source.add(origins);
 List<String> result = source.stream().reduce((a, b) -> {
        List<String> results = new ArrayList<>();
 a.forEach(param1 -> {
            b.forEach(param2 -> {
                results.add(param1 + "-" + param2);
 });
 });
 return results;
 }).get();
 System.out.println(result);
}

以上是关于lambda 生成笛卡尔集的主要内容,如果未能解决你的问题,请参考以下文章

CROSS JOIN连接用于生成两张表的笛卡尔集

从反射生成的程序集中调用 lambda

克鲁斯卡尔算法是怎样判断是不是构成了回路

两个数据源的笛卡尔积

MySQL中inner join 和 cross join 的区别

C语言数据结构 克鲁斯卡尔算法求无向网的最小生成树。