Gap is a very user friendly program. To read a file with integers, the only thing you need 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;


So easy to remember....

Lisette


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

Reply via email to