.NET中的映射和精简 [英] Map and Reduce in .NET

查看:49
本文介绍了.NET中的映射和精简的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪些情况需要使用"地图和约简"算法?

What scenarios would warrant the use of the "Map and Reduce" algorithm?


该算法是否有.NET实现?


Is there a .NET implementation of this algorithm?

推荐答案

Map和Reduce的Linq等效项: 如果您很幸运拥有linq,则无需编写自己的地图和简化函数. C#3.5和Linq已经有了不同的名称.

Linq equivalents of Map and Reduce: If you’re lucky enough to have linq then you don’t need to write your own map and reduce functions. C# 3.5 and Linq already has it albeit under different names.

  • 地图为Select:

Enumerable.Range(1, 10).Select(x => x + 2);

  • 缩小为Aggregate:

    Enumerable.Range(1, 10).Aggregate(0, (acc, x) => acc + x);
    

  • 过滤器为Where:

    Enumerable.Range(1, 10).Where(x => x % 2 == 0);
    

  • https://www.justinshield.com/2011/06/mapreduce -in-c/

    这篇关于.NET中的映射和精简的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆