V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Leviathann
V2EX  ›  问与答

英语里函数的 identity 是啥? Java stream api 的 reduce 文档看不懂

  •  
  •   Leviathann · 2021-08-09 11:57:16 +08:00 · 703 次点击
    这是一个创建于 962 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Performs a reduction on the elements of this stream, using the provided identity, accumulation and combining functions. This is equivalent to:

    U result = identity;
    for (T element : this stream)
    result = accumulator.apply(result, element)
    return result;

    but is not constrained to execute sequentially.
    The identity value must be an identity for the combiner function. This means that for all u, combiner(identity, u) is equal to u.

    搜了下大概知道这个 combiner 是并行流合并子流 reduce 的结果用的,但是那个 combiner(identity, u) is equal to u.是啥意思
    2 条回复    2021-08-09 12:17:10 +08:00
    sosilver
        1
    sosilver  
       2021-08-09 12:11:12 +08:00 via Android
    wiki/Identity_element
    Leviathann
        2
    Leviathann  
    OP
       2021-08-09 12:17:10 +08:00 via iPhone
    @sosilver 原来如此,吃了数学的亏
    我一直以为物理数学里的 单位 都是 unit 。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3506 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:06 · PVG 19:06 · LAX 04:06 · JFK 07:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.