Hello,

When people distribute data in GAP format, they sometimes[1][2] do it using files that can be used with the Read() function, assigning the results to some predetermined named variables. This introduces a few problems, such as when wanting to read the results from a few files into a list, or when trying to read the results from within a function.

Two examples:

gap> PrintTo("file","a:=1;\n");
gap> b:=function() Read("file"); return a; end;;
Syntax error: warning: unbound global variable
b:=function() Read("file"); return a; end;;
                                    ^

Or:

gap> a:=2;
2
gap> b:=function() local a; a:=3; Read("file"); return a; end;;
gap> b();
3
gap> a;
1


I think that including the following counterparts to ReadAsFunction() might allow people to distribute the data in a more convenient way.

ReadAsList:=function(n)
  local f,e;
  f:=InputTextFile(n);
  e:=ReadAll(f);
  CloseStream(f);
  return EvalString(Concatenation("[",e,"]"));
end;


ReadAsExpression:=function(n)
  local f,e;
  f:=InputTextFile(n);
  e:=ReadAll(f);
  CloseStream(f);
  return EvalString(e);
end;



[1] http://math.shinshu-u.ac.jp/~hanaki/as/
[2] http://www.math.tu-dresden.de/~reichard/schur/
--
Matan.


_______________________________________________
Forum mailing list
Forum@mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to