monad和closure之间有什么区别? [英] What is the difference between a monad and a closure?

查看:128
本文介绍了monad和closure之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑阅读两者之间的定义。他们可以在定义上相交吗?或者我完全失去了?感谢。

i am kinda confused reading the definition between the two. Can they actually intersect in terms of definition? or am i completely lost? Thanks.

推荐答案

Closures作为单词倾向于使用,只是函数(或代码块,如果你喜欢)你可以像一条数据一样处理,并传递给其他函数等(关闭位是,无论你最终调用它,它的行为就像它是如果你调用它最初定义它)。 monad(大致)更像一个上下文,其中函数可以顺序链接在一起,并控制数据如何从一个函数传递到下一个函数。

Closures, as the word tends to be used, are just functions (or blocks of code, if you like) that you can treat like a piece of data and pass to other functions, etc. (the "closed" bit is that wherever you eventually call it, it behaves just as it would if you called it where it was originally defined). A monad is (roughly) more like a context in which functions can be chained together sequentially, and controls how data is passed from one function to the next.

这篇关于monad和closure之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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