[英]haskell flip simulation problems
flip' :: (a -> b -> c) -> (b -> a -> c)
flip' f = g
where g x y = f y x
I want to ask that in the above flip' function , it seems that flip' will return a function named g and gxy share the same value with fyx 我想问一下,在上面的flip'函数中,似乎flip'将返回一个名为g的函数,而gxy与fyx共享相同的值
however, in " where gxy = fyx " , fyx is a function call and will return a value, gxy will aslo return a value, so does it make sense that " where v2 = v1 "? 但是,在“ where gxy = fyx”中,fyx是一个函数调用并返回一个值,gxy也将返回一个值,那么“ where v2 = v1”有意义吗?
I know that the code will work but I want to know more about the way it make this happen. 我知道代码可以工作,但是我想更多地了解实现它的方式。
does anybody has an idea? 有人有主意吗? thank you so much
非常感谢
In where gxy = fyx
, gxy
is not a function call g
with parameters x
and y
. 在
where gxy = fyx
, gxy
不是具有参数x
和y
的函数g
。 It is a declaration of the function g
as a function taking 2 arguments x
and y
and evaluation to fyx
. 它是函数
g
的声明,它是一个具有2个参数x
和y
以及对fyx
求值的fyx
。
So it means flip'
given a function f
taking 2 arguments will evaluate to g
. 因此,这意味着
flip'
给一个函数f
服用2个参数将评估为g
。 g
itself being defined as swapping two arguments to call f
. g
本身被定义为交换两个参数以调用f
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.