rbonichon / intro-ocaml Goto Github PK
View Code? Open in Web Editor NEWA (partial) introduction to OCaml
A (partial) introduction to OCaml
Interesting intro
Typos:
L149: maximun --> maximum
L572: syntactilly --> syntactically
Code typos:
L315: let rec loop vars = --> let rec loop vars = function
L325: let rec loop vars = --> let rec loop vars = function
L825: "is_top" is not defined?
L866: let rec length match l with --> let rec length l = match l with
L1043: fun v2 -> v1 + v2 --> fun v2 -> Some (v1 + v2) ... Maybe?
L1093: (Eq, Int 3, Int) --> (Eq, Int 3, Int 4) ... Maybe?
Something seems wrong with the last OCaml example. I have:
...
let al =
List.map (( + ) max_int) [1;2;3;4;5;6;7;]
|> addition_list ;;
(*
val al : t =
Add (Int (-4611686018427387904),
Add (Int (-4611686018427387903),
Add (Int (-4611686018427387902),
Add (Int (-4611686018427387901),
Add (Int (-4611686018427387900),
Add (Int (-4611686018427387899), Int (-4611686018427387898)))))))
*)
Format.printf "%a@." pp_expr al ;;
(*
-4611686018427387904 +
-4611686018427387903 +
-4611686018427387902 +
-4611686018427387901 +
-4611686018427387900 + -4611686018427387899 + -4611686018427387898
- : unit = ()
*)
Tests with OCaml 4.09.0.
let h = Hashtbl.create 7 ;;
(* val h : ('_weak1, '_weak2) Hashtbl.t = <abstr> *)
Hashtbl.add h 1 2 ;;
(* - : unit = () *)
Hashtbl.add h 1 3 ;;
(* - : unit = () *)
Hashtbl.iter (fun k v -> Format.printf "%d -> %d@." k v) h ;;
(*
1 -> 3
1 -> 2
- : unit = ()
*)
More control structures: while ...
http://caml.inria.fr/pub/docs/manual-ocaml-4.09/expr.html#sec143
The 'lazy' expressions:
http://caml.inria.fr/pub/docs/manual-ocaml-4.09/coreexamples.html#sec15
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.