module Scalar: sig end
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
true
and false
Functional
.Chain
.GBF
.Math
. 'acell : any -> bool
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
'string2undef("toto")
return <undef: toto>
'undef2string : undef -> string
'undef2string(<undef: toto>)
return "toto"
'val2bool : any -> bool
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:
undef
is converted into false
.funct
is converted into false
.symbol
is converted into false
.int
is converted into true
if it is non-zero.
bint
is converted into true
if it is non-zero.
float
is converted into true
if it is different from 0.0
.
string
is converted into true
if its length is different
from 0.
posgbf
is converted into true
unless it represents the
identity element of the group lawsplx
is converted into true
if its dimension is different
from 0
.ncell
is converted into true
if its dimension is different
from 0
.gmap
XXXXXXX is converted into ????
.true
only if it is
non-empty. Alternatively, a en empty collection corresponds to a
false
value.
'not : any -> bool
returns the negation of the boolean value associated to its
argument. For example not(3) == false
.
and_and : any -> any -> bool
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
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
'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
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
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
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
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
true
if the argument is a posgbf and false
for any other value.
posgbf
is also the type of the simplex.