version 25, including all changes.
.
Rev |
Author |
# |
Line |
25 |
AristotlePagaltzis |
1 |
__ML__ is a family of StaticallyTyped functional ProgrammingLanguage~s with StrictEvaluation, PolymorphicTypes, HigherOrderFunctions, a higher-order module system. [ML] can be used interactively for learning, experimentation and testing, or it can be compiled. The two major dialects of [ML] are [OCaml] and [SML]. [SML] is a standardised language with several implementations. [OCaml] has a single OpenSource implementation, it extends [ML] with an [OOP] system. Both major dialects have compilers that produce native code that rival the speed of [C++], and extensive standard and third-party libraries. |
10 |
GianPerrone |
2 |
|
24 |
AristotlePagaltzis |
3 |
[Why YOU want to program in ML | http://www.schizomaniac.net/ml.html] gives you a tour of the features of [ML] that make it a good general-purpose programming language. It talks about [SML], but what it says applies to [OCaml] as well. |
10 |
GianPerrone |
4 |
|
22 |
AristotlePagaltzis |
5 |
!!!An example of [ML] code: |
10 |
GianPerrone |
6 |
|
24 |
AristotlePagaltzis |
7 |
<pre> |
|
|
8 |
__fun__ interpret_functionally (program : opcode list) : unit = |
|
|
9 |
(* Interprets a parsed [Brainf*ck] program using integers |
|
|
10 |
on a strip of TuringMachine tape as the memory. *) |
|
|
11 |
__let__ |
|
|
12 |
__val__ fresh_tape = Tape.make(0) |
|
|
13 |
__fun__ step (tape, op) = |
|
|
14 |
__let__ byte = Tape.read(tape) __in__ |
|
|
15 |
__case__ op __of__ |
|
|
16 |
Inc_ptr n => times(n, Tape.forward, tape) |
|
|
17 |
| Dec_ptr n => times(n, Tape.back, tape) |
|
|
18 |
| Inc_byte n => Tape.write(byte + n, tape) |
|
|
19 |
| Dec_byte n => Tape.write(byte - n, tape) |
|
|
20 |
| Putchar => ( putchar(byte) ; tape ) |
|
|
21 |
| Getchar => Tape.write(getchar(), tape) |
|
|
22 |
| Loop body => |
|
|
23 |
__if__ byte = 0 __then__ tape |
|
|
24 |
__else__ step (step_sequence (tape, body), op) |
|
|
25 |
__end__ |
|
|
26 |
__fun__ step_sequence (tape, oplist) = |
|
|
27 |
List.foldl(step, tape, oplist) |
|
|
28 |
__in__ |
|
|
29 |
ignore (step_sequence(fresh_tape, program)) |
|
|
30 |
__end__ |
|
|
31 |
</pre> |
10 |
GianPerrone |
32 |
|
24 |
AristotlePagaltzis |
33 |
(This is in [SML].) |
22 |
AristotlePagaltzis |
34 |
|
|
|
35 |
---- |
|
|
36 |
CategoryProgrammingLanguages, CategoryFunctionalProgrammingLanguages |