Menu: Home | bash | Compilers | Elixir | F# | Go | Haskell | OCaml | Octave | Perl | Python | R | Rust | Scala | SQL
- Web REPL
- A Concise Introduction to Objective Caml
- Awesome OCaml: A curated collection of awesome OCaml tools, frameworks, libraries and articles
- Real World OCaml
- 33 Learning oCaml videos
- Official OCaml Site
- Functional Programming in OCaml
- ML for the Working Programmer, 2nd Edition
- 99 Problems (solved) in OCaml
- https://www.reddit.com/r/ocaml/comments/49zzg6/oml_machine_learning_in_ocaml_composeconf_talk
- http://roscidus.com/blog/blog/2014/06/06/python-to-ocaml-retrospective
- https://news.ycombinator.com/item?id=7234855
- OCaml Data Structures - YouTube
- Merlin: Context sensitive completion for OCaml in Vim and Emacs
- A brief introduction to OCaml
- http://www.reddit.com/r/ocaml/comments/39pxqg/what_are_the_most_common_bugs_in_ocamlfunctional
- http://www2.lib.uchicago.edu/keith/ocaml-class/home.html
- http://www2.lib.uchicago.edu/keith/ocaml-class/userdefined.html
- https://ocaml.org/learn/tutorials/ocaml_and_the_web.html
- Beginner's guide to OCaml beginner's guides.
- F# for fun and profit
- http://www.infoq.com/presentations/jane-street-caml-ocaml
- Why We Use OCaml
- https://www.reddit.com/r/ocaml/comments/3ifwe9/what_are_ocamlers_critiques_of_haskell
- Why OCaml, why now?
- https://www.reddit.com/r/ocaml/comments/4b2oot/dealing_with_strings_in_ocaml_for_a_beginner/
- https://michipili.github.io/essay/2016/04/11/ocaml-on-operations.html
- Generated OCaml bindings for Amazon Web Services
- Getting started with F#
- https://www.reddit.com/r/fsharp/comments/4ggl1c/getting_started_with_f_via_the_linux_command_line/
- http://stackoverflow.com/questions/179492/f-changes-to-ocaml
- http://web.archive.org/web/20080410181630/http://research.microsoft.com/fsharp/manual/ml-compat.aspx
- http://www.hammerlab.org/2015/08/11/introducing-oml-a-small-ocaml-library-for-numerical-computing/
- https://www.youtube.com/watch?v=czZ18YtZlaw
(* Addition *)
1 + 1
- Variables
let pi = 3.1416;;
let () = print_endline "Hello, World!"toplevel
let average a b =
(a +. b) /. 2.0;;
average;;
let rec // recursion
my_ref := 100;- Functions
A function always has exactly one parameter, and returns one result.
(* In this case, the one argument is a tuple, and the one result is a tuple. *)
let swap (x, y) = (y, x);;let sum (x, y) = x + y;;
sum(3, 5);;
let max (x, y) = if x > y then x else y;;
max(9, 5)
let hi () =
print_string "hello\n";;(*
Here, the one argument is the unit, (), which is a value--it is not syntax to indicate an empty parameter list. Similarly, the unit is returned as a result.
*)
print_newline ();;use "myFile.sml"The most common functions are in the "Pervasives module," which means you don't have to do anything special to use them
open String;;
length "hello";;Identifiers must begin with a lowercase letter or underscore, and may contain letters, digits, underscores, and single quotes.
[2; 3; 5; 7] Only the :: operator (LISP cons) and @ operator (list concatenation) can be used without opening the List module or prefixing the function name with List. .
5 :: [6; 7]
[5] @ [6; 7]
List.nth [3; 5; 7] 2
List.rev [1; 2; 3](5, "hello", ~16)open Char;;
Char.uppercase 'a'The name of an exception must begin with a capital letter.
You can declare new types of exceptions, with or without a parameter
(* One line *)
(*
* Multi-line
*)
(*
* (* Embedded *)
*)
- brew install opam