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
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 "?
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
. It is a declaration of the function g
as a function taking 2 arguments x
and y
and evaluation to fyx
.
So it means flip'
given a function f
taking 2 arguments will evaluate to g
. g
itself being defined as swapping two arguments to call f
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.