[GAP Forum] File input

Marc Roeder marc_roeder at web.de
Tue Feb 3 09:24:49 GMT 2009


Dear Don,

I suppose you already have a programme which converts lists into cycles.
So all you need is a piece of code which reads a file and outputs a list.
Suppose the file contains lists of integers separated by line breaks as in your example.

LoadPackage("io");                   ## package for handling input-output streams
input:=InputTextFile("a.txt");     ## open an input stream attached to the file
list:=[];
repeat
linestring:=ReadLine(input);    ## read next line from "input" as a string
if linestring<>fail
then
Add(list, EvalString(NormalizedWhitespace(linestring)));
fi;
until linestring=fail;
CloseStream(input);                  ## don't forget to close all streams you opened!

Now all you have to do is convert all lists in "list" to cycles.

Hope that helps,

marc


__________________________________________________________________
Deutschlands größte Online-Videothek schenkt Ihnen 12.000 Videos!*
http://entertainment.web.de/de/entertainment/maxdome/index.html




More information about the Forum mailing list