User Tools

Site Tools


cs_lang:ocaml

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cs_lang:ocaml [2011/07/12 11:29] cedriccs_lang:ocaml [2012/04/29 11:44] (current) cedric
Line 1: Line 1:
-====== Learning Objective Caml ======+====== Presentation ====== 
 +===== Paradigm ==== 
 +  * multi-paradigm: imperative, functional, object-oriented.
  
 +===== Typing discipline =====
 +  * static typed;
 +  * strongly typed;
 +  * inferred.
 +
 +
 +====== Learning Objective Caml ======
   * [[http://caml.inria.fr/ocaml/ | Official Website]];   * [[http://caml.inria.fr/ocaml/ | Official Website]];
   * [[http://caml.inria.fr/pub/docs/oreilly-book/ | Developing Applications With Objective Caml]] (in [[http://www.pps.jussieu.fr/Livres/ora/DA-OCAML/ | french]]).   * [[http://caml.inria.fr/pub/docs/oreilly-book/ | Developing Applications With Objective Caml]] (in [[http://www.pps.jussieu.fr/Livres/ora/DA-OCAML/ | french]]).
Line 6: Line 15:
  
 ====== Simple examples ====== ====== Simple examples ======
 +===== Increment a number =====
 <code ocaml> <code ocaml>
 # let inc n = n+1;; # let inc n = n+1;;
Line 13: Line 22:
 # inc 2;; # inc 2;;
 - : int = 3 - : int = 3
 +
 +
 +# Alternative:
 +# let inc = (+) 1;;
 +val inc : int -> int = <fun>
 </code> </code>
  
Line 46: Line 60:
 let rec parity = function let rec parity = function
   | [] -> []   | [] -> []
-  | x::-> (x mod 2 == 0)::(func t);;+  | x::-> (x mod 2 == 0)::(parity l);;
 val func : int list -> bool list = <fun> val func : int list -> bool list = <fun>
  
cs_lang/ocaml.1310462981.txt.gz · Last modified: 2011/07/12 11:29 by cedric