Caml program examples
This directory contains some examples of Objective Caml programs.
The examples can either be compiled and executed as standalone
programs (just type
make in the subdirectory), if speed
is important you can use the optimizing compiler by typing
make opt, or else run interactively the examples under
ocaml, by executing
in the appropriate directory. (The graphics programs must
be run under a specialized interactive system,
that you can create using
ocamlmktop -custom -o ocamlgraph
Examples marked (*) are taken from the book ``Le langage Caml'', by
Pierre Weis and Xavier Leroy (InterEditions, 1993 && 1999). Messages and
identifiers may be in French and may contain accented letters (ISO 8859-1
encoding). You'll need an 8-bit clean system to read them.
Examples marked (G) assume installed the portable graphics library
(as found in the
otherlib/graph directory of the
Objective Caml distribution).
One file programs
A set of simple, basic, and slightly advanced programs.
See the eng.html file.
Contains also the three all-time favorites: Fibonacci,
Eratosthene's sieve, and the Unix
- colwheel: (G)
The "color wheel" (color space in HSV coordinates).
Needs at least 256 colors to look good.
- spirals: (G)
Explore a family of flashy curves. (Use spir on a color screen
and spir-bw on a black and white screen.)
- showsort: (G)
Graphic animation of sorting algorithms.
- hanoi: (*)(G)
Animated towers of Hanoi. Uses lists and strings.
- doctor: (*)
A (English-speaking) clone of Eliza.
- docteur: (*)
A (French-speaking) clone of Eliza.
If you can translate this
program in any other language than english, please contact
Graphical User Interface
- camltk: (*)
A set of programs to learn using the Caml/Tk graphical user
interface (GUI). From simple «hello world» programs to an
advanced tetris game. Some examples are from the book ``Le
langage Caml'', by Pierre Weis and Xavier Leroy
(InterEditions, 1999). See the eng.html file in the directory.
Those programs are in the corresponding directories. They are
complete independant applications that have a Makefile to handle
their recompilation. Those examples can be quite involved.
This is a simple desk calculator that illustrates the use of camllex
- picomach: (*)
An assembler and simulator for a RISC processor.
- grep: (*)
Regular expressions and automata.
- compress: (*)
File compression and decompression (Huffman).
- demonstr: (*)
- minicaml: (*)
An interpreter and typechecker for a subset of Caml.
This is the implementation of A Small Language, as described in
part 3 of ``Functional Programming using Caml Light'', by
Michel Mauny and Guy Cousineau.
- minilogo: (*) (G)
An interpreter for a small language with turtle graphics.
Some examples of lexer/parser programs for simple to moderately
Parsing/lexing of a simple language of mathematical expressions.
Perform a simple treatment on abstract syntax trees (translation
of some function into simple algebraic counterparts).
Semantic treatment of a more complex Matlab-like language. Return
a polish pseudo-code representation of the expression.
- pascal: (*)
An interpreter and compiler for a subset of Pascal.
The compiler generates code for the
The Knuth-Bendix completion procedure for rewriting systems.
Taken from some course notes by Gerard Huet.
config directory does not contain examples, but configuration
files used to generate the Makefiles.