F# lets you turn operators into functions by surrounding them with (
)
: for instance, (+)
is of type int -> int -> int
::
and []
can both be represented by List<_>.Cons
and List<_>.Empty
respectively. Keep in mind though that the former takes a tuple as an argument. These are here so lists can be created in languages other than F#.
> List.Cons(4, List.Empty);;
val it : int list = [4]
> 4::[];;
val it : int list = [4]
> List.Cons(4, List.Empty);;
val it : int list = [4]
> List.Cons;;
val it : 'a * 'a list -> 'a list = //'
> List.Empty;;
val it : int list = []