div class="arc-summary mt-1" 本文介绍了为什么使用后向管道运算符而不是函数链?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! /div h3 class="mb-1"问题描述/h3 p为什么使用反向管道运算符而不是函数链接?/pprecodelet distanceFromOrigin aPoint =让平方 x = x * xsqrt(code/prep对比/pprecodelet distanceFromOrigin aPoint =让平方 x = x * x方格|code/prep/pdiv class="h2_lin" 解决方案 /divp因为左结合(codef | g | x/code 被解析为 code(f |g) <| x/code 可惜不是 codef <| (g <| x)/code 等价于 codex |> g |> f/code),我发现它只有在你想删除括号时才有用(而不是 codef(长表达式)/code,你写 codef <| long expression/code)./pWhy use a backward pipe operator instead of a function chaining?/pprecodelet distanceFromOrigin aPoint = let square x = x * x sqrt (square aPoint.x + square aPoint.y)/code/prepvs/pprecodelet distanceFromOrigin aPoint = let square x = x * x sqrt <| square aPoint.x + square aPoint.y/code/prep/pdiv class="h2_lin" 解决方案 /divpBecause of the left associativity (codef <| g <| x/code is parsed as code(f <| g) <| x/code and sadly not as codef <| (g <| x)/code which is equivalent to codex |> g |> f/code), I found it useful only when you want to remove parentheses (instead of codef (long expression)/code, you write codef <| long expression/code)./p p这篇关于为什么使用后向管道运算符而不是函数链?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!/p