Concatenative topics
Concatenative meta
Other languages
Meta
ML is a family of general-purpose, strong-typed, non-pure functional languages. The most known derivatives of ML are Standard ML and OCaml.
Features:
Standard ML implementations:
OCaml:
Example code (in OCaml):
(* An implementation of the factorial computing function
* in different coding styles.
* Note that the argument shall be >= 0
**)
(* Functional style *)
let rec fact_1 n =
match n with
0 -> 1
| n -> n * fact_1 (n - 1)
;;
(* Imperative style *)
let rec fact_2 n =
if n = 0 then 1
else n * fact_2 (n - 1)
;;
(* Imperative style without the recursion *)
let fact_3 n =
let result = ref 1 in
if n > 0 then
for i = 1 to n do result := !result * i done
else result := 0;
!result
;;
This revision created on Fri, 28 Sep 2012 08:11:42 by Cybercoma