[GAP Forum] Runtime

Frank Lübeck frank.luebeck at math.rwth-aachen.de
Fri Jul 18 15:10:04 BST 2014


On Fri, Jul 18, 2014 at 09:42:34AM -0400, Tim Kohl wrote:
> One thing to note about using Print for diagnostics is that sometimes
> the output may be buffered so that you don't always see the loop index
> as the loop is proceeding. In that instance the Display() command is
> a better option since it's not buffered and so you'll get 'real time'
> information.
> 
> 	-Tim

Dear Tim, dear Forum,

By default GAP does some buffering (and line breaking magic) of the current 
output line. It may be useful to know that there is the "flush character"
'\c' which flushes the output. Also, an explicit line break '\n' flushes the
output. Compare the following loops:

for i in [1..10] do Print(i, " "); Sleep(1); od;

for i in [1..10] do Print(i, "\n"); Sleep(1); od;

for i in [1..10] do Print(i, " \c"); Sleep(1); od;

And finally a fancy variant:

for i in [1..10] do 
  Print(TextAttr.home,TextAttr.delline," i =",String(i,4)," \c"); 
  Sleep(1); 
od; Print("\n");

Best regards,
   Frank
-- 
///  Dr. Frank Lübeck, Lehrstuhl D für Mathematik, Pontdriesch 14/16,
\\\                    52062 Aachen, Germany
///  E-mail: Frank.Luebeck at Math.RWTH-Aachen.De
\\\  WWW:    http://www.math.rwth-aachen.de/~Frank.Luebeck/



More information about the Forum mailing list