読者です 読者をやめる 読者になる 読者になる

OCaml getting started

Install

On ubuntu

Prerequisite on 15.04

sudo apt-get install curl build-essential m4 zlib1g-dev libssl-dev ocaml ocaml-native-compilers opam

Prerequisite on 14.04

sudo add-apt-repository ppa:avsm/ppa
sudo apt-get update
sudo apt-get install ocaml ocaml-native-compilers camlp4-extra opam

Setup OCaml

opam init
eval `opam config env`
opam switch 4.02.3
eval `opam config env`
opam install core utop

Append the snippet to ~/.ocamllist

#use "topfind";;
#thread;;
#camlp4o;;
#require "core.top";;
#require "core.syntax";;

open Core.Std

On Mac

brew install ocaml opam

Run

eval `opam config env`
utop

Syntax

list and tuple

list

Elements of list are separated by ;

tuple

Elements of list are separated by ,

Thus, a list of tuples are represented as below

["tuple_1_el_1", "tuple_1_el_2"; "tuple_2_el_1, "tuple_2_el_2"]