"Fossies" - the Fresh Open Source Software Archive

Member "KASH3-lib-archindep-2008-07-31/lib/kash.g" (3 Sep 2008, 4436 Bytes) of package /linux/misc/old/KASH3-lib-archindep-2008-07-31.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 InstallDocumentation(rec(
    3 name := "Comment",
    4 kind := "KEYWORD",
    5 short := "Comments in KASH3 start with '#'.  All text on a line after '#' "+
    6 "is ignored by KASH3.",
    7 ex := ["# this is a comment"]
    8 ));
    9 
   10 
   11 #/*TEX***TEX***TEX***TEX***TEX***TEX***TEX***TEX***TEX***TEX***TEX***TEX***TEX*
   12 #
   13 #USERDEF   
   14 #
   15 #FXN       GAP
   16 #
   17 #SHORTDOC  GAP-Emulation-Mode  
   18 #
   19 #LONGDOC   Initializes the GAP3 (groups algorithms and programing) emulation
   20 #          mode.  Not all functions are available.  There is NO DOCUMENTATION.         
   21 #          Please see the GAP3 documentation for a description of the functions.
   22 #
   23 #EXAMPLE   @
   24 #          GAP();
   25 #
   26 #**HISTORY*|*HISTORY***HISTORY***HISTORY***HISTORY***HISTORY***HISTORY**HISTORY
   27 #
   28 #**KASH***KASH***KASH***KASH***KASH***KASH***KASH***KASH***KASH***KASH***KASH*/
   29 
   30 InstallDocumentation(rec(
   31 kind := "FUNCTION",
   32 name := "GAP",
   33 sin := [],
   34 sou := [],
   35 short :=
   36 "Initializes the GAP3 (groups algorithms and programing) emulation "+
   37 "mode.  Not all functions are available.   KASH3 provides NO DOCUMENTATION. "+
   38 "Please refer to the GAP3 documentation for a description of the functions."
   39 ));
   40 
   41 GAP := function()
   42   ReadLib("../gap/lib/gap.kash");
   43   Print("\n");
   44 end;
   45 
   46 InstallDocumentation(rec(
   47 kind := "FUNCTION",
   48 name := "IsOdd",
   49 sin := [[elt-ord^rat,"b"]],
   50 sou := [[elt-alg^boo]],
   51 short :=
   52 "Return 'TRUE' if 'b' is odd",
   53 ex :=  ["IsOdd(5)"],
   54 see := [DocHash("IsEven(elt-ord^rat)")]
   55 ));
   56 
   57 #####################################################################
   58 
   59 IsOdd := function(b)
   60   return not IsEven(b);
   61 end;
   62 
   63 #####################################################################
   64 
   65 _BindNames_ := function(S,L)
   66 local i;
   67 
   68   AssignNames_(S,L);
   69   for i in [1..Size(L)] do
   70     Bind(L[i],S.(i));
   71   od;
   72 end; 
   73 
   74 InstallMethod(
   75 rec(
   76 kind := "FUNCTION",
   77 name := "BindNames_",
   78 sin := [[str,"S"],[list,"L"]],
   79 short :=
   80 "Define global variables whose names are given in 'L' which contain the generators of 'S'",
   81 ex :=  ["CY := PolynomialAlgebra(C); BindNames_(CY,[\"Y\"]);"],
   82 see := [DocHash("BindName_(str,string)"),DocHash("AssignNames_(rng,seq(string))")]
   83 ),_BindNames_);
   84 
   85 
   86 _BindName_ := function(S,name)
   87 
   88   AssignNames_(S,[name]);
   89   Bind(name,S.1);
   90 end; 
   91 
   92 InstallMethod(
   93 rec(
   94 kind := "FUNCTION",
   95 name := "BindName_",
   96 sin := [[str,"S"],[string,"name"]],
   97 short :=
   98 "Define a global variables whose name is given by 'name' which contains the (first) generator of 'S'",
   99 ex :=  ["CY := PolynomialAlgebra(C); BindName_(CY,\"Y\");"],
  100 see := [DocHash("BindNames_(str,list)"),DocHash("AssignNames_(rng,seq(string))")]
  101 ),_BindName_);
  102 
  103 ######################################################################
  104 
  105 __VERBOSE:= Alist();
  106 
  107 InstallDocumentation(rec(
  108 kind := "FUNCTION",
  109 name := "SetVerbose",
  110 sin := [[string,"S"],[elt-ord^rat,"n"]],
  111 short := "Set the verbose level of 'S' to 'n'.",
  112 see := [DocHash("GetVerbose(string)"),
  113          DocHash("PrintVerbose(string,elt-ord^rat,nof(any))")]
  114 ));
  115   SetVerbose:= function(s,n)
  116   if Type(n) <> elt-ord^rat then 
  117     Error("SetVerbose: Verbose levels must be integers."); 
  118   fi;
  119   if Type(s) <> string then 
  120     Error("SetVerbose: Verbose labels must be strings."); 
  121   fi;
  122   PutAssoc_(__VERBOSE,s,n);
  123 end;
  124 
  125 InstallDocumentation(rec(
  126 kind := "FUNCTION",
  127 name := "GetVerbose",
  128 sin := [[string,"S"]],
  129 sou := [[elt-ord^rat,"n"]],
  130 short := "Get the verbose level of 'S'.",
  131 see := [DocHash("GetVerbose(string)"),
  132          DocHash("PrintVerbose(string,elt-ord^rat,nof(any))")]
  133 ));
  134 GetVerbose:= function(s)
  135 return Assoc(__VERBOSE,s);
  136 end;
  137 
  138 InstallDocumentation(rec(
  139 kind := "FUNCTION",
  140 name := "PrintVerbose",
  141 sin := [[string,"S"],[elt-ord^rat,"n"],[nof(any)]],
  142 short := "If the verbose level of 'S' is greater 'n' then print information.",
  143 see := [DocHash("GetVerbose(string)"),
  144          DocHash("SetVerbose(string,elt-ord^rat)")]
  145 ));
  146 PrintVerbose:=function(arg)
  147 local m;
  148 
  149   if Size(arg) < 3 then
  150     Error("PrintVerbose: needs three or more arguments"); 
  151   fi;
  152   m := GetVerbose(arg[1]);
  153   if Type(m) <> elt-ord^rat then return; fi;
  154   if Type(arg[2]) <> elt-ord^rat then 
  155     Error("PrintVerbose: second argument mus be an integer.");
  156   fi;
  157   if m>=arg[2] then
  158     _CallFunction(Print,arg{[3..Size(arg)]});
  159   fi;
  160 end;
  161 
  162 
  163 InstallDocumentation(rec(
  164 kind := "FUNCTION",
  165 name := "Assert",
  166 sin := [[any,"A"]],
  167 short := "If 'A' is not 'TRUE' then inform the user that the assertion has failed.",
  168 ex := ["Assert(2=3);"]
  169 ));
  170 Assert := function(A)
  171  if not A then 
  172    Print("Assertion failed \n");
  173  fi;
  174 end;
  175 
  176