3 ms·
My preferred alternative to OCaml is definitely F#. The stdlib rocks and it has all the type inferred goodness of OCaml.
by fleitz 16y ago
My preferred alternative to OCaml is definitely F#. The stdlib rocks and it has all the type inferred goodness of OCaml.
- MichaelGG 16y agoTo compare, in F# you'd have: > let add3 x = x + 3 val add3 : int -> int Plain numeric literals are int (32-bit integer). To make it generic: > let inline add3 x = - let one = LanguagePrimitives.GenericOne in x + one + one + one;; val inline add3 : ^a -> ^e when ( ^a or ^b) : (static member ( + ) : ^a * ^b -> ^c) and ^b : (static member get_One : -> ^b) and ( ^c or ^b) : (static member ( + ) : ^c * ^b -> ^d) and ( ^d or ^b) : (static member ( + ) : ^d * ^b -> ^e) Perhaps not pretty, but inlining provides a quick way around some limitations on generics. While strings are not arrays, they are sequences (IEnumerable in .NET). Sequences can be infinite, so there's no Seq.reverse. But: > "hello" |> Seq.toArray |> Array.rev ;; val it : char [] = [|'o'; 'l'; 'l'; 'e'; 'h'|]