本文介绍了Haskell函数组成(。)和函数应用($)成语:正确使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我一直在阅读Real World Haskell,我已经接近尾声了,但是一个风格的问题一直在我和(。)和($)运算符的关系。 当你编写一个函数,它是其他函数的组合,你写它: f = g。但是当你把一些东西应用到这些函数的结尾时,我写成这样: > k = a $ b $ c $ value 但是这本书会这样写: k = a。 b。 c $ value 现在对我来说,他们看起来功能相当,他们在我的眼中做同样的事情。然而,我看起来越多,我看到的人就越多,按照本书的方式编写函数:先使用(。),然后只使用($)来附加一个值来计算批次它与许多美元组成)。有没有理由使用的书的方式比使用所有($)符号好得多?还是有一些最好的做法,在这里,我没有得到?或者是多余的,我不应该为它担心吗?谢谢。解决方案我想我可以从权威机构回答这个问题。 是否有理由使用比使用所有($)符号好的书籍方式? 没有特殊的原因。布莱恩和我都喜欢减少线路噪声。 。比 $ 该书使用 f。 G 。 h $ x 语法 I have been reading Real World Haskell and I am nearing the end but a matter of style has been niggling at me to do with the (.) and ($) operators.When you write a function that is a composition of other functions you write it like:f = g . hBut when you apply something to the end of those functions I write it like this:k = a $ b $ c $ valueBut the book would write it like this:k = a . b . c $ valueNow to me they look functionally equivalent, they do the exact same thing in my eyes. However, the more I look, the more I see people writing their functions in the manner that the book does: compose with (.) first and then only at the end use ($) to append a value to evaluate the lot (nobody does it with many dollar compositions). Is there a reason for using the books way that is much better than using all ($) symbols? Or is there some best practice here that I am not getting? Or is it superfluous and I shouldn't be worrying about it at all? Thanks. 解决方案 I guess I can answer this from authority. Is there a reason for using the books way that is much better than using all ($) symbols?There's no special reason. Bryan and I both prefer to reduce line noise. . is quieter than $As a result, the book uses the f . g . h $ x syntax 这篇关于Haskell函数组成(。)和函数应用($)成语:正确使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 08:09