Hits :
2632
ocaml.org[link1]
some notes on
ocaml[link2]
facts:
- ML is a general-purpose functional programming language
- Caml is a dialect of the ML
- OCaml is the most popular variant of the Caml language
- Caml Light's successor is OCaml
- OCaml is also known as: Objective Caml
Documentation and userΆs manual[link3]
ONE
ebal@mylaptop ~$ ocaml
OCaml version 4.00.1
# 1+2*3;;
- : int = 7
# 1;;
- : int = 1
# 1.1;;
- : float = 1.1
# 'a';;
- : char = 'a'
# "a";;
- : string = "a"
# abc;;
Error: Unbound value abc
# "abc";;
- : string = "abc"
# true;;
- : bool = true
# false;;
- : bool = false
# (1<2);;
- : bool = true
# (1>2);;
- : bool = false
# ["hello", "world"];;
- : (string * string) list = [("hello", "world")]
# ["hello"; "world"];;
- : string list = ["hello"; "world"]
# "a" :: ["hello"; "world"];;
- : string list = ["a"; "hello"; "world"]
Two
1. integer * float
# 2 * 3.14 ;;
Error: This expression has type float but an expression was expected of type
int
# 2.0 * 3.14 ;;
Error: This expression has type float but an expression was expected of type
int
# 2,0 * 3,14 ;;
- : int * int * int = (2, 0, 14)
# 2 *. * 3.14 ;;
Error: Syntax error
# 2.0 *. 3.14 ;;
- : float = 6.28
2. Unbound
# 2.0 *. pi ;;
Error: Unbound value pi
(fun is function)
# fun pi -> 2.0 *. pi ;;
- : float -> float = <fun>
(περνάς το 3.14 ως argument)
# ( fun pi -> 2.0 *. pi ) 3.14 ;;
- : float = 6.28
3. functional
let pi = 3.14;;
let result = fun r -> r *. pi ;;
result 2.0 ;;
result 5.0 ;;
[link2] http://caml.inria.fr/ocaml/index.en.html
[link3] http://caml.inria.fr/pub/docs/manual-ocaml-4.00/index.html
[link4] http://mirror.ocamlcore.org/ocaml-tutorial.org/index.html