An ordered set of instructions. It reads input, follows rules, and produces output.
Workspace
OCaml
typed functional programming compilers tools and formal methods
Definition first
What OCaml means
OCaml is a programming language for writing exact instructions, often used for typed functional programming compilers tools and formal methods. Start with one mental model: input goes through steps and becomes output.
main.mlRun ocaml main.mlHabit Use pattern matching and keep type signatures readableA value is data. A variable is the name you use to hold and reuse that data.
A named piece of work. It takes input, does one job, and can return a result.
OCaml is the place that actually runs code from main.ml.
First readable code
Program output
entry point output syntax print_intprint_int 42
Output 42Language lineage
OCaml family tree
See where OCaml comes from, which languages feel close, and what to learn next.
Zero base path
Question bank
Search before practice
Pick a stage or search across the open programming bank. Jump straight to the matching drill.
OCaml practice 1
OCaml question 1. Choose the statement that matches printing a value.
OCaml practice 2
OCaml question 2. Choose the statement that matches naming a value.
OCaml practice 3
OCaml question 3. Choose the statement that matches reusable function.
OCaml practice 4
OCaml question 4. Choose the statement that matches basic collection.
OCaml practice 5
OCaml question 5. Choose the statement that matches printing a value.
OCaml practice 6
OCaml question 6. Choose the statement that matches naming a value.
OCaml practice 7
OCaml question 7. Choose the statement that matches reusable function.
OCaml practice 8
OCaml question 8. Choose the statement that matches basic collection.
OCaml practice 9
OCaml question 9. Choose the statement that matches printing a value.
OCaml practice 10
OCaml question 10. Choose the statement that matches naming a value.
OCaml practice 11
OCaml question 11. Choose the statement that matches reusable function.
OCaml practice 12
OCaml question 12. Choose the statement that matches basic collection.
OCaml practice 13
OCaml question 13. Choose the statement that matches printing a value.
OCaml practice 14
OCaml question 14. Choose the statement that matches naming a value.
OCaml practice 15
OCaml question 15. Choose the statement that matches reusable function.
OCaml practice 16
OCaml question 16. Choose the statement that matches basic collection.
OCaml practice 17
OCaml question 17. Choose the statement that matches printing a value.
OCaml practice 18
OCaml question 18. Choose the statement that matches naming a value.
Multiple choice
OCaml practice 1
OCaml question 1. Choose the statement that matches printing a value.
print_int 42
Reference
Patterns for main.ml
ocaml main.mlentry point output syntax print_int
Program output
print_int 42
- Run the smallest file first
- Print one known value
- Check the output before adding more code
variables assignment types let
Values and names
let total = 42 let () = print_int total
- Give values readable names
- Keep one idea per line while learning
- Trace the value before changing it
function collection List
Functions and collections
let add a b = a + b let scores = [40; 2] let () = print_int (List.length scores)
- Keep functions small
- Return useful values
- Use the common collection before reaching for frameworks