-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I hear that F# is derived from OCaml. How true is this statement? That is to say, are the resources available for learning OCaml useful to someone who wants to learn F#? What are the major differences between the two languages (aside from the fact that F# is .NET)?
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Can the following polymorphic functions
let id x = x;;
let compose f g x = f (g x);;
let rec fix f = f (fix f);; (*laziness aside*)
be written for types/type constructors or modules/functors? I tried
type 'x id = Id of 'x;;
type 'f 'g 'x compose = Compose of ('f ('g 'x));;
type 'f fix = Fix…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
After learning the basic syntax, reading some non-trivial code is a fast way to learn a language. We can also learn how to design a library/software during reading others' code.
I have following lists.
A Chess program in OCaml by Tomek Czajka.
Hal Daumé has written several machine learning libraries…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Code:
let rec get_val (x, n) = match x with
[] -> -1
| if (n=0) then (h::_) -> h
else (_::t) -> get_val(t, n-1)
;;
Error message:
Characters 55-57:
| if (n=0) then (h::_) - h
^^
Error: Syntax error
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hello world!
I’m trying to implement a tail-recursive list-sorting function in OCaml, and I’ve come up with the following code:
let tailrec_merge_sort l =
let split l =
let rec _split source left right =
match source with
| [] -> (left, right)
| head :: tail ->…
>>> More