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

IF_SUBPACKAGE_VERSION[IF_mathematica] := "dev";


IF_CAS_DESCRIPTION[IF_mathematica] :=
[ "Mathematica",
"Mathematica is a computer algebra system originally developed by Stephen Wolfram and sold by his \
company Wolfram Research.",
"http://www.wolfram.com/products/mathematica/index.html" ];


IF_EXEC_NAME[IF_mathematica] := "math";
#IF_EXEC_FULL_PATH[IF_mathematica] := "";
IF_EXEC_OPTIONS[IF_mathematica] := [];

IF_QUIT_COMMAND[IF_mathematica] := "Quit[]";
IF_DISPLAY_VERSION[IF_mathematica] := "$Version";

# IF_FIRST_COMMAND[IF_mathematica] := "";
IF_FIRST_PROMPT[IF_mathematica] := "\n\nIn[1]:= ";

if not IsBound( IF_PROMPT_NR[IF_mathematica] )  then
    IF_PROMPT_NR[IF_mathematica]:= 1;
fi;

IF_PROMPTS[IF_mathematica] :=
function ( OUT )
    local  prompt;
    prompt := Concatenation( "\nIn[", String( IF_PROMPT_NR[IF_mathematica] + 1 ), "]:= " );
    return PositionSublist( OUT, prompt ) <> fail;
end;

IF_FUNC_REMOVE_PROMPT[IF_mathematica] := 
function ( OUT )
    local  prompt;
    prompt := Concatenation( "\nIn[", String( IF_PROMPT_NR[IF_mathematica] + 1 ), "]:= " );
    OUT := OUT{[ 1 .. Length( OUT ) - Length( prompt ) ]};
    if Length( OUT ) > 8 and OUT{[ 1 .. 5 ]} = "\nOut["  then
        OUT := OUT{[ 9 + Length( String( IF_PROMPT_NR[IF_mathematica] ) ) .. Length( OUT ) - 1 ]};
    fi;
    if Length( OUT ) > 10 and OUT{[ 1 .. 10 ]} = "FullForm= "  then
        OUT := OUT{[ 11 .. Length( OUT ) ]};
    fi;

    IF_PROMPT_NR[IF_mathematica] := IF_PROMPT_NR[IF_mathematica] + 1;
    return OUT;
end;

IF_BRACKETS[IF_mathematica] := [ "[", "]" ];
IF_ASSIGN[IF_mathematica] := ":=";
IF_END_COMMAND[IF_mathematica] := "";
IF_IS_THERE_PROMPT[IF_mathematica] := true;
IF_FUNC_TYPE[IF_mathematica] := "Head";
IF_TYPE_IS_QUOTED[IF_mathematica] := false;

IF_STRING_ARE_QUOTED[IF_mathematica] := true;
IF_FUNC_STRING[IF_mathematica] := "ToString"; # StringForm?
IF_FUNC_DISPLAY[IF_mathematica] := "FullForm";
IF_PROHIBITED_CHARS[IF_mathematica] := [  ];


IF_DATA_TYPES[IF_mathematica] := rec(


Symbol := [
"symbol (extract name using SymbolName)",
,
,
IdFunc
],


String := [
"character string \"cccc\" (extract characters using Characters)",
IsString and IsStringRep,
IF_ParseGapString,
IF_EvalString
],


Integer := [
"integer (extract digits using IntegerDigits)",
IsInt,
String,
Int
],


Real := [
"approximate real number (extract digits using RealDigits)",
],


Rational := [
"rational number (extract parts using Numerator and Denominator)",
IsRat,
String,
function ( obj )
    local  p1, p2, p3;
    p1 := Position( obj, '[' );
    p2 := Position( obj, ',' );
    p3 := Position( obj, ']' );
    return Int( obj{[ (p1 + 1) .. (p2 - 1) ]} ) / Int( obj{[ (p2 + 2) .. (p3 - 1) ]} );
end
],


Complex := [
"complex number (extract parts using Re and Im)",
IsGaussRat,
function ( obj )
    local  real, imaginary;
    real := x -> (x + ComplexConjugate( x )) / 2;
    imaginary := x -> (x - ComplexConjugate( x )) * -1 / 2 * E( 4 );
    return Concatenation( "( ", IF_ConvertFromGap( IF_mathematica, real( obj ) ),
        " + I*(", IF_ConvertFromGap( IF_mathematica, imaginary( obj ) ), ") )" );
end,
IdFunc ####
]
 
);


# HelpBrowserNotebook[ ]

# Character strings in Mathematica can contain any sequence of characters. 
# They are input in the form "ccccc".  



