You can use the static method:
let ls = List.Cons (1, [2..5])
or the operatorโs detailed name:
let ls = op_ColonColon (1, [2..5])
(noted with F # 3.0, older versions may behave differently. For example, MSDN offers op_Cons )
In both cases, there is no way to deduce the arguments. Numeric operators are defined as follows:
let inline ( * ) (x:int) (y:int) = ...
List concatenation, however, requires a tuple, and this also answers your question,
What is the reason for this?
In fact, (::) not a normal operator (a standalone function or type element), but a union case . Here's how List<'T> is defined in F # sources :
type List<'T> = | ([]) : 'T list | (::) : Head: 'T * Tail: 'T list -> 'T list
So, if your goal is to partially apply the arguments, the only good solution would be to write a wrapper function, as @pad suggested.
source share