Title: Theory / Unimportant / CS / Programming / oCaml / Manual{ / 01 Core;
Tags: hasNotNewEffectReturnsMeaning some_instruction computer_to_instruction FromInstruction type declaration fromCommand fromCommandLine fromMath mathToDef

Typ: bool
Meaning: Booleans
Language: ocaml
Chapter: 1
Section: 2

Typ: t list
Meaning: The type of lists of elements of type t
Language: ocaml
Chapter: 1
Section: 2
Variables: t a type,

Typ: 'letter
Meaning: A type variable
Language: ocaml
Chapter: 1
Section: 2

Name: A functional function
Definition: A function which takes a function as argument.
Chapter: 1
Section: 3
Name2: Higher order function

Name: An enumeration type
Definition: A variable type where all alternatives are constants.
Chapter: 1
Section: 4

Typ: t array
Meaning: A mutable sequence of n elements of type t, with n fixed when the object is created
Language: ocaml
Chapter: 1
Section: 5

Typ: t ref
Meaning: A reference to an element of type t
Language: ocaml
Chapter: 1
Section: 5

Extension: ml
Description: OCaml code
Means: ocaml
Other fields (not shown on cards):
Chapter: 1
Section: 9

Instruction: ;;
Effect: End of sentence
Language: ocaml
Chapter: 1

Instruction: let funName var_1 ... var_n = code
Meaning: Creating a function given arg_1, ..., arg_n , execute code where var__i is interpreted as arg_i
Language: ocaml
Chapter: 1
Identifier: funName
Variables: vari of type t_i
Typ: t_1 => ... => t_n => typeOfCode

Instruction: let rec funName var_1 ... var_n = code
Meaning: funName can be used in code
Language: ocaml
Chapter: 1
Variables: vari : t_i
Typ: t_1 => ... => t_n => typeOfCode
Similar to: let funName var_1 ... var_n = code

Instruction: true
Effect: the true Boolean
Language: ocaml
Chapter: 1
Section: 2

Instruction: false
Effect: the false Boolean
Language: ocaml
Chapter: 1
Section: 2

Instruction: e :: l
Language: ocaml
Chapter: 1
Section: 2
Returns: the list whose head is e and whose tail is l
Typ: 'a -> 'a list -> 'a list

Instruction: [expr_1, ..., expr_n]
Effect: Execute the n expr_i, let v_i be their values.
The list of size n whose ith element is v_i
Language: ocaml
Chapter: 1
Section: 2
Assuming: all t_i are equal
Typ: t_1 list

Typ: type typeName ={
(mutable) name_1:type1;
...
(mutable) name_n:typen;
}
Meaning: The objects with n parameters, named name_1,.., name_n with respective type type_1, ..., type_n. If mutable appears before the ith name, its value can be modified after the creation
Language: ocaml
Chapter: 1
Section: 4, 5
Name: record

Typ: type typeName=
| Constructor1 of type_1
| ...
_
| Constructorn of type_n
Meaning: An object whose form is one of the n forms.
If it is of the i th form, its parameter is of type type_i
Language: ocaml
Chapter: 1
Section: 4
Name: variant

Instruction: match expr with
| pattern_1 when cond_1-> code_1,
_ ...
| pattern_n when cond_1-> code_n,
Effect: Let i minimal such that expr match against the pattern i, satisfies cond_i. Then code_i is executed.
Raise Match_failure if no such i exists
Language: ocaml
Chapter: 1
Section: 4

Instruction: [| expr_1, ..., expr_n |]
Effect: Execute the n expr_i, let v_i be their values.
The array of size n whose ith element is v_i
Language: ocaml
Chapter: 1
Section: 5
Variables: expr_i of type t_i
Assuming: all t_i are equal
Typ: t_1 array

Instruction: ref expr
Effect: execute expr, let v its value
Language: oCaml
Chapter: 1
Section: 5
Returns: A mutable value initialized to v

Instruction: !x
Effect: the value referenced by x
Language: ocaml
Chapter: 1
Section: 5
Variables: x : 'a ref

Instruction: x := expr
Effect: execute expr and assign its value to x.
Language: ocaml
Chapter: 1
Section: 5
Variables: x: 'a ref

Instruction: x.(i)
Effect: The ith element of x
Language: ocaml
Chapter: 1
Section: 5
Variables: x: 'a array,
i: int

Instruction: x.(i) <- expr
Effect: Execute expr and assign its value to the ith element of x
Language: ocaml
Chapter: 1
Section: 5
Variables: x: 'a array,
i: int,
expr: 'a

Instruction: exception excName of type
Effect: state that excName is an exception with a parameter whose type is type
Language: ocaml
Chapter: 1
Section: 6

Instruction: try
code
with
|ExceptionName_1 (pattern_1)-> code_1
..
|ExceptionName_n (pattern_n)-> code_n
Effect: execute code
If it raises an exception, try to match them as in a match ... with. If the exception match against no pattern, it is raised again
Language: ocaml
Chapter: 1
Section: 6
Variables: code, code_1, ..., code_n , all have the same type

Instruction: r.elt
Effect: Accessing the value associated to elt in r
Language: ocaml
Chapter: 1
Section: 5
Variables: r a record type containing an element elt of type t
Typ: t

Instruction: ocamlc file_1, ..., file_n
Effect: Compile the files in the given order. Each file can only reference files appearing before.
Similar to compiling a single file, where each file corresponds to a module.
Language: ocaml
Chapter: 1, 2
Section: 9, 5

Effect: The compiled code is in the file output
Context: ocamlc
Chapter: 1
Section: 9
Abbreviation: -o output