Science Fair Projects Ideas - Ocaml

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Ocaml

(Redirected from OCaml)

Objective Caml, OCaml for short, is an advanced programming language that is part of the ML family. It is developed and distributed as open-source by INRIA. Ocaml was created in 1996 as a Caml Light successor. Its authors include Xavier Leroy, Jerome Vouillon and Damien Doligez .

CAML originally stood for Categorical Abstract Machine Language. OCaml has not been based on this abstract machine for a long time.

OCaml shares the functional and imperative features of ML, but contains object-oriented concepts and minor syntax differences.

Features

Performance distinguishes OCaml from other ML languages. The runtime system was designed to be fast, efficient, and frugal in memory usage. Ocaml provides a bytecode compiler, a script interpreter or toplevel evaluation loop, and an optimizing native code compiler. Code generated by the native code compiler is typically comparable to C/C++ in efficiency. See The Computer Language Shootout Benchmarks.

OCaml features include a static type system, type inference, parametric polymorphism, tail recursion, pattern matching, first class lexical closures, functors (parametric modules), exception handling, and incremental generational automatic garbage collection. Its syntax is quite concise. The object system provides for multiple inheritance, object construction directly (by specifying methods for a unique object) or from classes, and structural subtyping (objects are of compatible types if their methods are compatible, regardless of what was inherited from what).

OCaml features are pragmatically balanced between expressivity, new features, ease of interfacing with existing systems and libraries and efficiency. Ocaml supports familiar functions such as printf, and a foreign function interface which permits easy linking with C primitives, including language support for efficient numerical arrays in formats compatible with both C and FORTRAN.

The OCaml distribution includes a preprocessor (permitting syntactical extensions), a debugger (capable of stepping backwards when investigating an error), a documentation generator, a profiler, and numerous general purpose libraries. The compiler is available for many platforms, including Unix, Windows, and Macintosh, with native code generation for major architectures (IA32, PowerPC, AMD64, Sparc, IA64, Alpha, HP/PA, MIPS, StrongARM), thus providing good portability.

Uses

Computer science

Natural science

OCaml is also widely used in physics, chemistry, biology and, more recently, bioinformatics:

Scientific computing OCaml examples.

Education

Ocaml is used as an introductory language in many universities, including:

OCaml is also used to teach Computer Science (mainly algorithms and complexity theories) in the French Classes Préparatoires (Preparation Courses), for students who choose to study Computer Science (and has almost replaced Pascal for that).

Programs written in OCaml

Commonly used:

  • MLDonkey - a popular multi-network P2P program
  • Unison file synchronizer

Fun programs:

See also

External links

Code examples

Hello World

  print_endline "Hello world!";;

Birthday paradox

The following OCaml script calculates the number of people who need to be in a room before the probability of two sharing the same birthday becomes larger than 50% (the so-called birthday paradox).

It also demonstrates OCaml as a scripting language. On a unix-like machine, save it to a file, chmod it to executable (chmod 0755 birthday.ml) and run it from the command line (./birthday.ml).

#!/usr/bin/ocamlrun ocaml

let size = 365. ;;

let rec loop p i =
  let p' = (size -. (float (i-1))) *. p /. size in
  if p' < 0.5 then
    Printf.printf "answer = %d\n" i
  else
    loop p' (i+1) ;;
loop 1.0 2

09-23-2007 01:00:40
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice