/* $Header$*/ /* * Copyright © 2002 Keith Packard and Bart Massey. * All Rights Reserved. See the file COPYING in this directory * for licensing information. */ namespace History { poly[...] hist = {}; public void insert (poly v) /* * Insert 'v' in the history list */ { hist[dim(hist)] = v; } public poly fetch (int id) /* * Fetch history element 'id' */ { if (dim(hist) == 0) return <>; if (id <= 0) return hist[dim(hist)+id-1]; else return hist[id-1]; } public void show (string format, int args...) /* * show history elements */ { int from = 10, to = dim(hist); int id; if (dim(hist) == 0) return; if (dim(args) >= 1) from = args[0]; if (dim(args) >= 2) to = args[1]; else { from = dim(hist) - from; if (from < 1) from = 1; } for (id = from; id <= to; id++) { printf ("$%-4d\t", from); printf (format, fetch (id)); printf ("\n"); from++; } } }