Dear Forum,

It was pointed out that I should close the stream at the end of the function to 
avoid error messages if running the function multiple times, so the correct 
version is:

ReadIntegerListsFromFile:=function(file)
local l,f,i,a,r;
  f:=InputTextFile(file);
  a:=[];
  while not IsEndOfStream(f) do
    l:=ReadLine(f);
    if l<>fail then
      l:=Chomp(l); # remove trailing CR/LF
      r:=[];
      for i in SplitString(l," ,") do # separate by SPACE or ,
        if Length(i)>0 then
          Add(r,Int(i));
        fi;
      od;
      Add(a,r);
    fi;
  od;
  CloseStream(f);    # <== New line
  return a;
end;

Best,

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

Reply via email to