  
  [1X19 [33X[0;0YIO[133X[101X
  
  
  [1X19.1 [33X[0;0YReading and writing elements to a file[133X[101X
  
  [33X[0;0YThe  functions  [2XReadGenerators[102X  ([14X19.1-1[114X) and [2XWriteGenerators[102X ([14X19.1-2[114X) can be
  used to read or write, respectively, elements of a semigroup to a file.[133X
  
  [1X19.1-1 ReadGenerators[101X
  
  [29X[2XReadGenerators[102X( [3Xfilename[103X[, [3Xnr[103X] ) [32X function
  [29X[2XReadOldGenerators[102X( [3Xfilename[103X[, [3Xnr[103X] ) [32X function
  [6XReturns:[106X  [33X[0;10YA list of lists of semigroup elements.[133X
  
  [33X[0;0YIf  [3Xfilename[103X  is  the name of a file created using [2XWriteGenerators[102X ([14X19.1-2[114X),
  then  [10XReadGenerators[110X returns the contents of this file as a list of lists of
  elements of a semigroup.[133X
  
  [33X[0;0YIf  the  optional second argument [3Xnr[103X is present, then [10XReadGenerators[110X returns
  the elements stored in the [3Xnr[103Xth line of [3Xfilename[103X.[133X
  
  [33X[0;0YIf  you  want  to  read generators from a file written using [10XWriteGenerators[110X
  from  a  version  of  [5XSemigroups[105X  before  version  3.0.0,  then  you can use
  [10XReadOldGenerators[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xfile := Concatenation(SEMIGROUPS.PackageDir,[127X[104X
    [4X[25X>[125X [27X"/data/tst/testdata");;[127X[104X
    [4X[25Xgap>[125X [27XReadGenerators(file, 13);[127X[104X
    [4X[28X[ <identity partial perm on [ 2, 3, 4, 5, 6 ]>, [128X[104X
    [4X[28X  <identity partial perm on [ 2, 3, 5, 6 ]>, [1,2](5)(6) ][128X[104X
  [4X[32X[104X
  
  [1X19.1-2 WriteGenerators[101X
  
  [29X[2XWriteGenerators[102X( [3Xfilename[103X, [3Xlist[103X[, [3Xappend[103X] ) [32X function
  [6XReturns:[106X  [33X[0;10Y[10XIO_OK[110X or [10XIO_ERROR[110X.[133X
  
  [33X[0;0YThis  function  provides  a  method for writing collections of elements of a
  semigroup to a file. The resulting file can be further compressed using [10Xgzip[110X
  or [10Xxz[110X.[133X
  
  [33X[0;0YThe  argument  [3Xlist[103X  should be a list of elements, a semigroup, or a list of
  lists of elements, or semigroups.[133X
  
  [33X[0;0YThe argument [3Xfilename[103X should be a string containing the name of a file where
  the  entries  in  [3Xlist[103X  will  be  written  or an [5XIO[105X package file object; see
  [2XIO_File[102X ([14XIO_File???[114X) and [2XIO_CompressedFile[102X ([14XIO_CompressedFile???[114X).[133X
  
  [33X[0;0YIf  the  optional  third  argument  [3Xappend[103X is given and equals [10X"w"[110X, then the
  previous  content  of  the  file is deleted and overwritten. If the optional
  third  argument is [10X"a"[110X or is not present, then [10Xlist[110X is appended to the file.
  This  function  returns [2XIO_OK[102X ([14XIO_OK???[114X) if everything went well or [2XIO_ERROR[102X
  ([14XIO_ERROR???[114X) if something went wrong.[133X
  
  [33X[0;0Y[10XWriteGenerators[110X appends a line to the file [3Xfilename[103X for every entry in [3Xlist[103X.
  If any element of [3Xlist[103X is a semigroup, then the generators of that semigroup
  are   written   to   [3Xfilename[103X.  More  specifically,  the  list  returned  by
  [2XGeneratorsOfSemigroup[102X  ([14XReference:  GeneratorsOfSemigroup[114X) is written to the
  file.[133X
  
  [33X[0;0YThe file [3Xfilename[103X can be read using [2XReadGenerators[102X ([14X19.1-1[114X).[133X
  
  [33X[0;0YFrom  Version  3.0.0  onwards  the  [5XSemigroups[105X  package  used the [5XIO[105X package
  pickling  functionality;  see  [14XPickling  and unpickling???[114X for more details.
  This  approach  is  used because it is more general and more robust than the
  methods  used by earlier versions of [5XSemigroups[105X, although the performance is
  somewhat worse, and the resulting files are somewhat larger.[133X
  
  [33X[0;0YA  file  written  in  the  old  format  can  be read using [2XReadOldGenerators[102X
  ([14X19.1-1[114X).[133X
  
  [1X19.1-3 IteratorFromPickledFile[101X
  
  [29X[2XIteratorFromPickledFile[102X( [3Xfilename[103X ) [32X function
  [29X[2XIteratorFromOldGeneratorsFile[102X( [3Xfilename[103X ) [32X function
  [6XReturns:[106X  [33X[0;10YAn iterator.[133X
  
  [33X[0;0YIf  [3Xfilename[103X  is  a  string  containing  the  name  of  a file created using
  [2XWriteGenerators[102X  ([14X19.1-2[114X),  then [10XIteratorFromPickledFile[110X returns an iterator
  [10Xiter[110X  such that [10XNextIterator(iter)[110X returns the next collection of generators
  stored in the file [3Xfilename[103X.[133X
  
  [33X[0;0YThis function is a convenient way of, for example, looping over a collection
  of  generators  in  a  file  without  loading  every object in the file into
  memory.  This  might  be  useful  if the file contains more information than
  there is available memory.[133X
  
  [33X[0;0YIf you want to get an iterator for a file written using [10XWriteGenerators[110X from
  a   version   of   [5XSemigroups[105X   before  version  3.0.0,  then  you  can  use
  [10XIteratorFromOldGeneratorsFile[110X.[133X
  
