# The variables are explained in the file gap/data.g
# name := number;

IF_mupad := 80;


##############################################################################
# Administrative data


IF_SUBPACKAGE_VERSION[IF_mupad] := "dev";

IF_CAS_DESCRIPTION[IF_mupad] :=
[ "MuPAD",
"MuPAD is a mathematical expert system for doing symbolic and exact algebraic computations",
"http://www.mupad.de/", "http://www.mupad.com/", "http://www.sciface.com/" ];


##############################################################################
# Low level data


IF_EXEC_NAME[IF_mupad] := "mupad";
#IF_EXEC_FULL_PATH[IF_mupad] := "";
IF_EXEC_OPTIONS[IF_mupad] := [ "-P", "e" ];


IF_QUIT_COMMAND[IF_mupad] := ";quit;";
IF_DISPLAY_VERSION[IF_mupad] := "version()";


IF_FIRST_COMMAND[IF_mupad] := "PRETTYPRINT := FALSE";

IF_FIRST_PROMPT[IF_mupad] := "\n>> ";
IF_PROMPTS[IF_mupad] :=[ "\n>> ", ">> " ];
IF_FUNC_REMOVE_PROMPT[IF_mupad] := function ( OUT )
    if Length( OUT ) > 7 and OUT{[ 1 .. 7 ]} = "Error: "  then
        Error( "in Maple: ", OUT{[ 8 .. Length( OUT ) ]} );
    fi;
    return OUT{[ 1 .. Length( OUT ) - Length( IF_PROMPTS[IF_mupad][1] ) ]};
end;
IF_IS_THERE_PROMPT[IF_mupad] := true;


##############################################################################
# High level data


IF_ASSIGN[IF_mupad] := ":=";
IF_END_COMMAND[IF_mupad] := "";
IF_END_COMMAND_NO_OUTPUT[IF_mupad] := ":";
IF_FUNC_TYPE[IF_mupad] := "domtype"; # "type"
IF_TYPE_IS_QUOTED[IF_mupad] := false;

IF_FUNC_DISPLAY[IF_mupad] := "";

IF_STRING_ARE_QUOTED[IF_mupad] := true;
IF_FUNC_STRING[IF_mupad] := "expr2text";
IF_PROHIBITED_CHARS[IF_mupad] := Union( [ 0 .. 31 ], [ 127, 128, 254, 255 ] ); # ?


##############################################################################
# data types data


# http://www.mupad.de/doc30+M531102500c7.html#x4-70003


IF_DATA_TYPES[IF_mupad] := rec(


DOM_ARRAY := [
"arrays",
],


DOM_BOOL := [
"the logical constants TRUE, FALSE and UNKNOWN",
obj -> IsBool( obj ) and ( obj = true or obj = false ),
function( obj )
    if obj = true  then
        return "TRUE";
    elif obj = false  then
        return "FALSE";
    fi;
end,
function( obj )
    if obj = "TRUE"  then
        return true;
    elif obj = "FALSE"  then
        return false;
    elif obj = "UNKNOWN"  then
        return fail;
    fi;
end
],



DOM_DOMAIN := [
"data structures",
],


DOM_EXPR := [
"expressions",
,
,
# _and, _assign, _concat, _div, _divide, _equal, _equiv, _exprseq, _fconcat, _fnest, _implies, _in, 
# _index, _intersect, _invert, _lastContentOutput, _lazy_and, _lazy_or, _leequal, _less, _minus, _mod, 
# _mult, _negate, _or, _plus, _power, _range, _save, _seqgen, _seqin, _subtract, _unequal, _union, _xor
],


DOM_FAIL := [
"the object FAIL",
obj -> obj = fail,
obj -> "FAIL",
obj -> fail,
],

DOM_FLOAT := [
"real floating-point numbers",
],

DOM_FUNC_ENV := [
"function environments",
],

DOM_IDENT := [
"identifiers",
],

DOM_INT := [
"integer numbers",
IsInt,
String,
Int
],

DOM_INTERVAL := [
"floating point intervals",
],

DOM_NIL := [
"the object NIL",
],

DOM_NULL := [
"the void object null()",
],

DOM_POLY := [
"polynomials",
IsRationalFunction and IsPolynomial,
],

DOM_PROC := [
"procedures",
],

DOM_RAT := [
"rational numbers",
IsRat,
String,
Rat
],

DOM_STRING := [
"strings",
IsString and IsStringRep,
IF_ParseGapString,
IF_EvalString
],

DOM_TABLE := [
"tables",
],

DOM_VAR := [
"local variables in procedures",
],


DOM_COMPLEX := [
"complex numbers",
IsGaussRat,
function ( obj )
    local  real, imaginary;
    real := x -> (x + ComplexConjugate( x )) / 2;
    imaginary := x -> (x - ComplexConjugate( x )) * -1 / 2 * E( 4 );
#? E := proc(n) description "returns  the primitive <n>-th root of unity"; begin exp(2*I*Pi/n) end proc
    return Concatenation( "( ", IF_ConvertFromGap( IF_mupad, real( obj ) ),
        " + I*(", IF_ConvertFromGap( IF_mupad, imaginary( obj ) ), ") )" );
end,
function( obj, name )
    return IF_Maple_op( IF_mupad, obj, name, function ( x, y ) return x + E( 4 ) * y; end );
end
],



DOM_LIST := [
"lists",
obj -> IsDenseList( obj ) and ForAll( obj, y -> IF_Type(IF_mupad, y) <> fail ),
obj -> IF_ParseGapList( IF_mupad, obj, "[", "]" ),
function( obj, name ) return IF_Maple_op( IF_mupad, obj, name, Add ); end
],

DOM_SET := [
"sets",
obj -> IsDenseList( obj ) and ForAll( obj, y -> IF_Type(IF_mupad, y) <> fail ),
obj -> IF_ParseGapList( IF_mupad, obj, "{", "}" ),
function( obj, name ) return IF_Maple_op( IF_mupad, obj, name, Add ); end
]



# [ "DOM_EXEC", "DOM_FRAME", "DOM_POINT", "DOM_POLYGON" ]


);


