> <\body> Language> This document is a tutorial introduction to the language. Identifiers of variables are formed using letters, digits and the special characters and . Identifiers must start with a letter or . Identifiers should match the regular expression .\ To assign a value to a variable, we use the operator :\ <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> a1 := 1 <|unfolded-io> <\textput> Constant values can be assigned by the operator , and cannot be modified hereafter: <\unfolded-io> <|unfolded-io> a1_? == 2; a1_? <|unfolded-io> <\textput> The operator will be used for instance to define functions which definition should not be modified. \ <\unfolded-io> <|unfolded-io> cst: Int == 11111*111111 <|unfolded-io> : <\unfolded-io> <|unfolded-io> mut: Int := 1010*1234 <|unfolded-io> : > <\textput> \; Below, we try to modify a constant and we get an error: <\unfolded-io> <|unfolded-io> cst := - cst <|unfolded-io> <\errput> :: , \ cst := - cst ~~~ <\textput> \; whereas modifying a variable is not a problem:\ <\unfolded-io> <|unfolded-io> mut := - mut <|unfolded-io> : <\input> <|input> \; In this section, we describe the basic types, which exist by default in the interpreter. For the other types provided by the extension packages, see their documentation. The default type of an object is and the corresponding variable type is : <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> a := x <|unfolded-io> <\unfolded-io> <|unfolded-io> type a <|unfolded-io> > <\input> <|input> \; The usual boolean constant are and . The equality and inequality tests are and .\ <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> a = a <|unfolded-io> <\unfolded-io> <|unfolded-io> a != a <|unfolded-io> <\textput> To build boolean expression, we use the operators \ , and the negation operator : <\unfolded-io> <|unfolded-io> a = b and a != c <|unfolded-io> <\unfolded-io> <|unfolded-io> a = b or a != c <|unfolded-io> <\unfolded-io> <|unfolded-io> !( a = b or a != c) <|unfolded-io> <\textput> in its signature:>\ <\unfolded-io> <|unfolded-io> help Boolean <|unfolded-io> >>>> <\unfolded-explain|Available functions> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> = : (Vector (Generic), Vector (Generic)) -\ Boolean> = : (String, String) -\ Boolean> = : (Double, Double) -\ Boolean> = : (Int, Int) -\ Boolean> : (Vector (Generic), Vector (Generic)) -\ Boolean> : (String, String) -\ Boolean> : (Double, Double) -\ Boolean> : (Int, Int) -\ Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> = : (Vector (Generic), Vector (Generic)) -\ Boolean> = : (String, String) -\ Boolean> = : (Double, Double) -\ Boolean> = : (Int, Int) -\ Boolean> : (Vector (Generic), Vector (Generic)) -\ Boolean> : (String, String) -\ Boolean> : (Double, Double) -\ Boolean> : (Int, Int) -\ Boolean> Alias (Boolean)> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Syntactic> String> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Int> Boolean> Int> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> > <\input> <|input> \; Strings can be braced into double quotes . Inside such a string a double quote must be blackslashed. In order to avoid blackslashing one can use the stronger string delimiters . <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> s1 := "This is a string" <|unfolded-io> <\unfolded-io> <|unfolded-io> s2 : String := "Print \\"foo\\" " <|unfolded-io> <\textput> Not that in this definition, we specify that the variable is of type . \; <\unfolded-io> <|unfolded-io> s2 := /" Print "foo" "/ <|unfolded-io> <\textput> The concatenation of strings can be done by the operator \> <\unfolded-io> <|unfolded-io> s3 := s2 \\" and \\"fii\\" " <|unfolded-io> <\textput> It is also possible to use the in place concatenation operator \> on a variable: <\unfolded-io> <|unfolded-io> s2 \\/" and "fuu" "/ <|unfolded-io> <\textput> \; The length of a string is given by the operator <\unfolded-io> <|unfolded-io> #s1 <|unfolded-io> <\textput> Search forward the position of a substring. If it is not found, the result is , otherwise it returns the position of the first character. <\unfolded-io> <|unfolded-io> search_forwards (s2, "Print", 0) <|unfolded-io> <\unfolded-io> <|unfolded-io> replace(s2, "fuu", "haha") <|unfolded-io> <\textput> in its signature:> <\unfolded-io> <|unfolded-io> help String <|unfolded-io> >>>> <\unfolded-explain|Available functions> Boolean> Int> Document> Document> Document> Document> Document> Document> Document> Document> String> String> Port> String> \ : (Alias (String), String) -\ Alias (String)> \ : (Port, String) -\ Port> = : (String, String) -\ Boolean> : (String, String) -\ Boolean> Boolean> \ : (String, String) -\ String> = : (String, String) -\ Boolean> : (String, String) -\ Boolean> Alias (String)> Double> Int> Literal> String> String> String> String> String> String> Boolean> Boolean> Port> String> Exception> Boolean> Boolean> Syntactic> String> String> String> String> String> String> Port> Port> Double> String> String> String> Port> String> Port> String> String> String> String> String> Int> Int> Port> Port> String> String> String> String> String> String> String> Boolean> String> String> Int> String> String> String> Generic> > <\input> <|input> \; An integer literal is a sequence of digits, possible preceded by a minus sign. It matches the regular expression . Examples: , . <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> a := 2 <|unfolded-io> <\textput> \; The usual arithmetic operators are available:\ <\unfolded-io> <|unfolded-io> a+3; a-5; a*a <|unfolded-io> <\textput> as well as the inplace operators : <\unfolded-io> <|unfolded-io> a += 1; a *= 2; a -= 3 <|unfolded-io> <\unfolded-io> <|unfolded-io> 5 div 2 <|unfolded-io> <\unfolded-io> <|unfolded-io> 5 mod 2 <|unfolded-io> <\textput> The default type for integers is . It corresponds to machine type . <\unfolded-io> <|unfolded-io> type(1) <|unfolded-io> <\textput> in its signature>: \ \ <\unfolded-io> <|unfolded-io> help Int <|unfolded-io> >>>> <\unfolded-explain|Available functions> Boolean> Int> Int> Int> Int> Int> Int> Int> Generic> Alias (Generic)> Vector (Generic)> Generic> String> Generic> Alias (Generic)> List (Generic)> Int> Int> = : (Int, Int) -\ Boolean> : (Int, Int) -\ Boolean> Boolean> = : (Int, Int) -\ Boolean> : (Int, Int) -\ Boolean> Tuple (Generic)> Int> Alias (Int)> Int> Int> String> String> Generic> Double> Int> Generic> Syntactic> Int> Int> Int> Int> Int> > By default, the floating point literals are converted to types. A floating literal is a sequence of digits with a decimal point inside and an optional exponent. It matches the regular expression .\ Note that is not permitted, >; \; <\unfolded-io> <|unfolded-io> 2.1 <|unfolded-io> <\unfolded-io> <|unfolded-io> 2.1*3 <|unfolded-io> <\unfolded-io> <|unfolded-io> 2.3/2-1 <|unfolded-io> <\unfolded-io> <|unfolded-io> type(1.1) <|unfolded-io> <\unfolded-io> <|unfolded-io> help Double <|unfolded-io> >>>> <\unfolded-explain|Available functions> Boolean> Double> Double> Double> = : (Double, Double) -\ Boolean> : (Double, Double) -\ Boolean> Boolean> = : (Double, Double) -\ Boolean> : (Double, Double) -\ Boolean> Double> Double> Alias (Double)> Double> Double> Double> Double> Int> String> Double> Double> Double> Int> Double> Boolean> Syntactic> Double> Double> Boolean> Double> Double> Double> Double> Double> Double> Boolean> Double> Double> Int> Double> Double> Double> Double> Double> Double> Double> > In order to have access to >, one can use the package |../../../numerix/doc/texmacs/index.en.tm>. In this case, the integer literals will yield numbers of type , based on integers: \; <\unfolded-io> <|unfolded-io> use "numerix"; type(1) <|unfolded-io> <\textput> For more details on the package , see . \; <\input> <|input> \; <\session|mathemagix|default> The type can be used to produce document outputs, represented as lisp-type expressions. It is automatically parsed by TeXmacs to display these outputs. \ <\unfolded-io> <|unfolded-io> type_mode?:=true <|unfolded-io> : <\unfolded-io> <|unfolded-io> 'x <|unfolded-io> : <\textput> \; <\unfolded-io> <|unfolded-io> '(f (x, y, z)) <|unfolded-io> >: <\unfolded-io> <|unfolded-io> '(f (x, y, z)) [2] <|unfolded-io> : <\unfolded-io> <|unfolded-io> $document ("Some ", $with ("color", "red", "red"), " text."; \ \ \ \ \ \ \ \ \ \ \ "Pythagoras said ", $math ('(a^2 + b^2 = c^2)), ".") <|unfolded-io> <\text> Some text. Pythagoras said +b=c>. : <\input> <|input> \; Vectors are sequence of elements, stored in an array and with a direct access through their index. Their type is parametrized by the type of the elements. The default type is . <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> v := [1,2,3] <|unfolded-io> > <\textput> \; The indices start from 0 : <\unfolded-io> <|unfolded-io> v[0]+v[1]+v[2] <|unfolded-io> <\textput> The length of a vector is given by the prefix operator : <\unfolded-io> <|unfolded-io> #v <|unfolded-io> <\textput> \; The concatenation of vectors is performed by the operator \>: <\unfolded-io> <|unfolded-io> w := v \\ [4,5] <|unfolded-io> > <\textput> \; The inplace concatenation of vectors is done by the operator \>: <\unfolded-io> <|unfolded-io> v \\ [1,2] <|unfolded-io> > <\textput> \; The classical operations on lists are available also on vectors: <\unfolded-io> <|unfolded-io> [car(v), cdr(v), cons(3,v)] <|unfolded-io> ,|]>> <\unfolded-io> <|unfolded-io> reverse v <|unfolded-io> > <\unfolded-io> <|unfolded-io> contains?(v,1) <|unfolded-io> <\unfolded-io> <|unfolded-io> help Vector(Generic) <|unfolded-io> >>>> <\unfolded-explain|Available functions> Boolean> Int> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Generic> Alias (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> \ : (Alias (Vector (Generic)), Vector (Generic)) -\ Alias (Vector (Generic))> = : (Vector (Generic), Vector (Generic)) -\ Boolean> : (Vector (Generic), Vector (Generic)) -\ Boolean> Boolean> \ : (Vector (Generic), Vector (Generic)) -\ Vector (Generic)> = : (Vector (Generic), Vector (Generic)) -\ Boolean> : (Vector (Generic), Vector (Generic)) -\ Boolean> Vector (Generic)> Vector (Generic)> Alias (Vector (Generic))> Generic> Generic> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Compound> Vector (Generic)> Boolean> Generic> Generic> Generic> Vector (Generic)> Vector (Generic)> Vector (Generic)> Boolean> Vector (Generic)> Vector (Generic)> Generic> Vector (Generic)> Int> Syntactic> Generic> Vector (Generic)> Vector (Generic)> Executable (Generic)> Vector (Generic)> Generic> Boolean> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> Vector (Generic)> > <\input> <|input> \; Tuples are written inside .... Elements are separated by .\ <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> v := (1,2,3) <|unfolded-io> > <\textput> \; Note the associativity of tuples: <\unfolded-io> <|unfolded-io> (1,(2,3)) <|unfolded-io> > <\unfolded-io> <|unfolded-io> v:= [1,2]; (v,((v))) <|unfolded-io> ,|)>> <\unfolded-io> <|unfolded-io> help Tuple(Generic) <|unfolded-io> >>>> <\unfolded-explain|Available functions> Tuple (Generic)> Generic> Generic> Generic> Generic> Alias (Generic)> Vector (Generic)> Tuple (Generic)> Compound> Boolean> List (Generic)> Generic> Generic> Vector (Generic)> > <\input> <|input> \; means the range [a,b], while stands for the half open range [a,b). <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> (1 to 4) <|unfolded-io> > <\unfolded-io> <|unfolded-io> 1 .. 4 <|unfolded-io> > <\textput> <\textput> Note that or are not tuples but iterators, that can be used to produce sequences: <\unfolded-io> <|unfolded-io> [1..6] <|unfolded-io> > <\unfolded-io> <|unfolded-io> [i*i \| i in 1 to 10] <|unfolded-io> > \; <\textput> Double iterators are also possible when matrix types are available:\ <\unfolded-io> <|unfolded-io> use "algebramix"; [i+j \| i in 0 to 9 \|\| j in 0..10] <|unfolded-io> |||||||||>>|]>> <\input> <|input> \; Tables allow to store the association between keys of one type and values of another type. They are defined by providing a default value. In the following example, the default value is : <\session|mathemagix|default> <\input> <|input> t := table(1); <\unfolded-io> <|unfolded-io> t[1] \ := -3; t[34] := \ 2 <|unfolded-io> <\unfolded-io> <|unfolded-io> t[0] <|unfolded-io> <\unfolded-io> <|unfolded-io> contains? (t,2) <|unfolded-io> <\unfolded-io> <|unfolded-io> help Table(Generic,Generic) <|unfolded-io> >>>> <\unfolded-explain|Available functions> Boolean> Int> Generic> Alias (Generic)> Generic> Alias (Generic)> Boolean> Alias (Table (Generic, Generic))> Boolean> Boolean> Syntactic> Generic> Generic> Generic> Generic> Table (Generic, Generic)> > <\input> <|input> \; The default type for tables used in the interpreter is . The condition construction is as follows: <\code> <\mmx-code> if condition then block1 [else block2] where is any expression that evaluates to a boolean. and are either one instruction or a block of instructions braced into .... The ... (here the part) means that the expression is optional. <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> if true then 1 <|unfolded-io> : <\unfolded-io> <|unfolded-io> if a = b then 1 else 2 <|unfolded-io> : <\unfolded-io> <|unfolded-io> if i = 0 then {\ \ \ x := 1; y := 2 } else {\ \ \ z := 3; mmerr \\ "error"\ } <|unfolded-io> |)>>: <\input> <|input> \; Loops are constructed as follows: <\code> <\mmx-code> [ E1] [ E2] [ E3] [ E4] block The is an instruction or a sequence of instructions delimited by .... exits the loop, and goes to the next step of the loop. <\session|mathemagix|default> <\unfolded-io|> for i in 1..3 do mmout \\ i \\ " "; <|unfolded-io> 1 2\ <\unfolded-io|> i := 0; while i \ 5 do { mmout \\ i \\ " "; i := i + 1 } <|unfolded-io> 0 1 2 3 4\ <\input> <|input> // do mmout \\ "no end "; // This loop has no end \; > A function definition is done as follows: <\code> <\mmx-code> name arg1: type1, arg2: type2, ...: returned_type == \ block The is either one instruction or several instructions in between . also provides a syntax for lambda expressions: <\code> <\mmx-code> (arg1: type1, arg2: type2, ...): returned_type ... Notice that any of the type specifications can be omitted, in which case the type is assumed to be .\ <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> f (x: String) :String == return x\\x <|unfolded-io> : <\unfolded-io> <|unfolded-io> f("ab") <|unfolded-io> : A function is called in the usual way: . If is unitary then can be omitted, but note that is equivalent to . Function call is always by value. <\textput> In the following definition, no type are specified so that the input and output type are assumed: <\unfolded-io> <|unfolded-io> f (x) == {\ \ \ a :Generic == x*x; \ \ \ return a\ }\ <|unfolded-io> : <\textput> When a function has only one argument, the parenthesis can be omitted. <\unfolded-io> <|unfolded-io> f 3.1 <|unfolded-io> : <\textput> The same name is used for the definition of two functions of types > Int>, > Generic>. The polymorphism of is resolved by the type of its argument: <\unfolded-io> <|unfolded-io> f "xx "\ <|unfolded-io> : <\unfolded-io> <|unfolded-io> f 2.1 <|unfolded-io> : <\textput> Local variables have to be declared with a type and an initial value: <\unfolded-io> <|unfolded-io> \ add_naive (a: Vector Generic) == {\ \ \ \ c : Generic := 0; for x in a do c := c + x;\ \ \ \ return c; \ } <|unfolded-io> : <\unfolded-io> <|unfolded-io> add_naive([1,2,3]) <|unfolded-io> : > <\textput> The definition of a postfix function is preceded by the keyword . The name of the function should start with a : <\unfolded-io> <|unfolded-io> \ postfix .sq(i : Int) : Int == { return i*i } <|unfolded-io> : <\unfolded-io> <|unfolded-io> 3.sq <|unfolded-io> : <\unfolded-io> <|unfolded-io> postfix .m (a: Int) (b: Int) : Double == { return 1.0*a*b } <|unfolded-io> : <\unfolded-io> <|unfolded-io> 3.m(3) <|unfolded-io> : <\textput> <\unfolded-io> <|unfolded-io> fib (n: Int): Int == \ \ if n \= 1 then 1 else fib (n-1) + fib (n-2) <|unfolded-io> : <\unfolded-io> <|unfolded-io> [fib n \| n in 1..10] <|unfolded-io> >: > <\unfolded-io> <|unfolded-io> shift (x: Int) (y: Int): Int == x + y <|unfolded-io> : <\unfolded-io> <|unfolded-io> shift 3 <|unfolded-io> : <\unfolded-io> <|unfolded-io> (shift 3) 4 <|unfolded-io> : <\unfolded-io> <|unfolded-io> map (shift 3, [ 1 to 20 ]) <|unfolded-io> >: > <\input> <|input> \; <\textput> \ Any function definition can be preceded by quantifiers ... or .... <\code> <\mmx-code> forall (R) gcd (p: Polynomial(R), q: Polynomial(R)): Polynomial(R) == {...} \ \ <\textput> <\textput> \ \ <\unfolded-io> <|unfolded-io> risky (x: Int): Double == { \ \ if x = 5 then raise "not in domain"; \ \ return 1 / (x - 5); } try { \ \ for i in 1 to 10 do mmout \\ i \\ " -\ " \\ risky i \\ "\\n"; \ \ catch (err: String) { mmout \\ "error: " \\ err \\ "\\n"; } }; <|unfolded-io> -\ -\ -\ -\ -\ error: not in domain <\input> <|input> \; A macro corresponds to a syntactic definition. No type is needed: <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> square x ==\ x*x <|unfolded-io> : <\unfolded-io> <|unfolded-io> square 2.1 <|unfolded-io> : <\unfolded-io> <|unfolded-io> square 2 <|unfolded-io> : <\unfolded-io> <|unfolded-io> disc(a,b,c) ==\ b*b - 4*a*c\ <|unfolded-io> : <\unfolded-io> <|unfolded-io> disc (1,2,3.001) <|unfolded-io> : <\textput> \; Macros can be usefull to define short and convenient names for types for instance: <\unfolded-io> <|unfolded-io> VG ==\ Vector Generic <|unfolded-io> >: <\unfolded-io> <|unfolded-io> f(a : VG) == car a <|unfolded-io> : <\unfolded-io> <|unfolded-io> f ([1,2]) <|unfolded-io> : <\input> <|input> \; \; <\session|mathemagix|default> <\textput> <\input> <|input> class Color == { \ \ mutable { r: Double; g: Double; b: Double; } \ \ constructor grey (x: Double) == { \ \ \ \ r == x; g == x; b == x; } \ \ constructor rgb (r2: Double, g2: Double, b2: Double) == { \ \ \ \ r == r2; g == g2; b == b2; } } <\unfolded-io> <|unfolded-io> rgb (1, 0, 0) <|unfolded-io> ,Color|)>>: <\input> <|input> flatten (c: Color): Syntactic == \ \ syntactic ('rgb (as_generic flatten c.r, \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ as_generic flatten c.g, \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ as_generic flatten c.b)); <\unfolded-io> <|unfolded-io> rgb (1, 0, 0) <|unfolded-io> >: <\input> <|input> mix (c1: Color, c2: Color, a: Double): Color == \ \ rgb (a * c1.r + (1-a) * c2.r, \ \ \ \ \ \ \ a * c1.g + (1-a) * c2.g, \ \ \ \ \ \ \ a * c1.b + (1-a) * c2.b); <\unfolded-io> <|unfolded-io> mix (rgb (1, 0, 0), grey (0.5), 0.5) <|unfolded-io> >: <\input> <|input> \; <\session|mathemagix|default> <\textput> The operator > can be used to convert a given type to another, provided that the corresponding function is defined. We show here an example of an explicit conversion from a class to the class :\ <\input> <|input> class Alpha_color == { \ \ mutable { c: Color; a: Double; } \ \ constructor alpha_color (c2: Color, a2: Double) == { c == c2; a == a2; } }; <\unfolded-io> <|unfolded-io> alpha_color (rgb(0,0,1), 0.5) <|unfolded-io> ,0.5|]>,Alpha_color|)>>: <\input> <|input> downgrade (ac: Alpha_color): Color == mix (ac.c, rgb(1,1,1), ac.a); <\unfolded-io> <|unfolded-io> alpha_color (rgb(0,0,0), 0.6) :\ Color <|unfolded-io> >: <\textput> In order to define implicit conversions from a type to another, one can use the function : <\input> <|input> upgrade (x: Double): Color == grey x; <\textput> \; We use implicitely in the instruction below to convert to a type: <\unfolded-io> <|unfolded-io> mix (1.0, rgb (0, 1, 0), 0.2) <|unfolded-io> >: <\unfolded-io> <|unfolded-io> mix (0.8, 0.2, 0.4) <|unfolded-io> >: <\input> <|input> postfix .greyed (c: Color): Color == (c.r + c.g + c.b) / 3; <\unfolded-io> <|unfolded-io> rgb (1, 0, 0).greyed <|unfolded-io> >: <\input> <|input> \; <\session|mathemagix|default> There is an output stream, which is called . It can be used with the operator \> to print strings: <\unfolded-io> <|unfolded-io> mmout <|unfolded-io> |)>>: <\unfolded-io> <|unfolded-io> mmout \\ "Hello\\n"; <|unfolded-io> Hello <\unfolded-io> <|unfolded-io> i := 3; mmout\\"The square of "\\i\\" is "\\i*i\\"\\n";\ <|unfolded-io> The square of is <\textput> \; The error stream, used to catch error message, is : \; <\input> <|input> mmerr \\"An error message"; <\textput> \; Output streams can also be defined from files. Here we add a string the the file : <\input> <|input> output_file_port ("toto.txt") \\ "Hi there\\n"; <\textput> \; and we load the contents of this file as a string: <\unfolded-io> <|unfolded-io> load ("toto.txt") <|unfolded-io> : Here are some usefull command to read and save contents in files. The command to read a file and to evaluate it is : <\session|mathemagix|default> <\input|> include "example.mmx" <\textput> \; The command to save a in a file is : <\input> <|input> save ("tmp.txt", "A string is stored in the file \\n in two lines"); <\textput> \; If now, you want to recover the content of a file, you can use the command : <\unfolded-io> <|unfolded-io> load "tmp.txt" <|unfolded-io> : \; <\textput> The files in a directory can be recovered by the command . The result is a vector of strings, which corresponds to the name of a file or a subdirectory: <\unfolded-io> <|unfolded-io> load_directory "." <|unfolded-io> ,,,,,,,,,,,,|]>>: > <\textput> \; To check if a file or a directory exists, one can use the predicate <\unfolded-io> <|unfolded-io> readable? "tmp.txt" <|unfolded-io> : <\textput> \; The function allows to load and use the types and functions exported in an external \ dynamic library: <\input|> use "numerix" <\textput> If this example, the library should be in the loading path. \; <\input> <|input> \; Several functions are available to interact with the environment. To get the value of a variable defined in the environment, one can use : <\session|mathemagix|default> <\unfolded-io|> get_env "PWD" <|unfolded-io> <\unfolded-io|> set_env ("DISPLAY", "arthur:0") <|unfolded-io> <\textput> To run a command in this environement, one can use the function : <\unfolded-io> <|unfolded-io> system "ls" <|unfolded-io> emacs_mode.en.tm how_to.en.tm index.en.tm installation.en.tm quick_start.en.tm shell.en.tm shell_tutorial.en.tm syntax.en.tm tmp.txt toto.txt : <\input> <|input> \; Comments starting with extend to the end of the physical line. Such a comment may appear at the start of a line or following whitespace or code, but not within a string literal. Multi-line comments must be braced into and can be nested. <\mmx-code> x := 1; // Assign 1 to x. \; y := 2; /{ This \ \ \ is multi-line \ \ \ comment about y. }/ . If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.>