Module Scalar


module Scalar: sig  end
Functions acting on scalar values: int, string, float, undef, splx, funct, posgbf, gmap, bint etc.

The values in MGS are typed. The universe of types is splitted in two: scalar or atomic values that cannot be decomposed and collections that are aggregate of simpler values. Scalar types includes


See : For functionnal values refer also to the chapter Functional.
See : For functions related to simplex, cf. the chapter Chain.
See : For functions related to posgbf, cf. the chapter GBF.
See : For various mathematical constants and arithmetics operators, cf. the chapter Math.

 'acell : any -> bool
Returns true if the argument is a acell and false for any other value.

acell is also the type of the abstract topological cells.

 'string2undef : string -> undef
Returns an undef value with its string argument as a comment
Example :'string2undef("toto") return <undef: toto>
 'undef2string : undef -> string
Returns the comment of an undef value as a string
Example :'undef2string(<undef: toto>) return "toto"
 'val2bool : any -> bool
Convert a value to a boolean.

Any MGS value can be converted into a boolean. This conversion occurs implicitly for instance in the condition of a if ... then ... else ... fi expression. This conversion can be done explicitly using the function val2bool. The conversion rules are the following:


 'not : any -> bool
any_bool

returns the negation of the boolean value associated to its argument. For example not(3) == false.

 and_and : any -> any -> bool
returns the logical conjunction of the two arguments.

The arguments can be any MGS value. See the function 'val2bool for the boolean interpretation of a value. && can be aslo written &.

The evaluation is lazy:

false && (?("Hello"); true)
does not print Hello to the terminal.

Warning: a && b is not an ordinary function call but a special form that is expansed during the parsing to if a then b else false fi. The quoted name does not exist.

 || : any -> any -> bool
returns the logical disjunction of the two arguments.

The arguments can be any MGS value. See the function 'val2bool for the boolean interpretation of a value.

The evaluation is lazy:

true || (?("Hello"); true)
does not print Hello to the terminal.

Warning a || b is not an ordinary function call but a special form that is expansed during the parsing to if a then true else b fi. The quoted name does not exist.

 'string_length : string -> int
Returns the length of it's string argument
 'string_get : string -> int -> string
string_get(s, n) returns character number n in string s. The first character is character number 0. The last character is character number string_length(s) - 1. Returns <undef> if n is outside the range 0 to string_length(s) - 1.
 'string_make : int -> string -> string
string_make(n, c) returns a fresh string of length n, filled with the first character of string c. Returns <undef> if n is negative or too big (currently, too big means greater than 16777211 characters).
 'string_sub : string -> int -> int -> string
string_sub(s, start, len) returns a fresh string of length len, containing the characters number start to start + len - 1 of string s. Returns <undef> if start and len do not designate a valid substring of s; that is, if start < 0, or len < 0, or start + len > string_length s.
 'string_index : string -> string -> int
string_index(s, c) returns the position of the leftmost occurrence in string s of the first character of string c. Returns <undef> if c does not occur in s.
 'string_rindex : string -> string -> int
string_rindex(s, c) returns the position of the rightmost occurrence in string s of the first character of string c. Returns <undef> if c does not occur in s.
 'string_index_from : string -> int -> string -> int
Same as string_index, but start searching at the character position given as second argument. string_index(s, c) is equivalent to string_index_from(s, 0, c).
 'string_rindex_from : string -> int -> string -> int
Same as string_rindex, but start searching at the character position given as second argument. string_rindex(s, c) is equivalent to string_rindex_from(s, string_length(s) - 1, c).
 'string_contains : string -> string -> bool
string_contains(s, c) tests if the first character of c appears in the string s.
 'string_contains_from : string -> int -> string -> bool
string_contains_from(s, start, c) tests if the first character of c appears in the substring of s starting from start to the end of s. Returns <undef> if start is not a valid index of s.
 'string_rcontains_from : string -> int -> string -> bool
string_rcontains_from(s, start, c) tests if the first character of c appears in the substring of s starting from the beginning of s to index stop. Returns <undef> if start is not a valid index of s.
 'gensym : symbol -> symbol
string -> symbol

gensym(s) generates a symbol from the string or the symbol s. When s is a string, unless the first character of s is a back quote, gensym(s) adds a back quote at the beginning of s:

gensym("foo")

returns

`foo1

and

gensym("`foo")

returns

`foo2

Obviously,

gensym(`foo)

returns

`foo3

The uniqueness is given by an integer that is concatenated at the end of the argument and incremented. gensym dosen't check if this integer is incremented out of range.

 'ncell : any -> bool
Returns true if the argument is a ncell and false for any other value.

ncell is also the type of the QMF topological cells.

 'gmap : any -> bool
Returns true if the argument is a gamap and false for any other value.

gmap is also the type of the Generalized Maps containing the QMF topological cells.

 'posgbf : any -> bool
Returns true if the argument is a posgbf and false for any other value.

posgbf is also the type of the simplex.