Is there a built-in “make pair” function or operator? I know this is trivial, but it would ease function composition in some cases.
Basically, just
let makePair a b = a, b
Can I also suggest Foogle?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, I don’t think there is a function like that in the F# library (and you also cannot treat
,as an operator, which is allowed in Haskell).F# lacks many other functions that are often used in function composition (or point-free style) including
flip : ('a -> 'b) -> 'b -> 'aandcurry : ('a * 'b -> c) -> 'a -> 'b - 'c). Frankly, I think that this is a good thing because it discourages people from writing code that is hard to read.Of course, there are many cases where using some function like this would give readable code, but it is really difficult to find the right ballance.