Karim BELABAS on Mon, 20 May 2002 22:13:37 +0200 (MEST)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Inputing a file of numbers

On Mon, 6 May 2002, Andrew John Walker wrote:
> I'm using the dos executable of GP/PARI V 2.0.20. Basically I have a
> large file consisting of integers on separate lines. I would like to
> be able to read them in separately, performing a set of operations
> on them in turn. The only command I can find that may be able to
> perform this is
> ? ?input
> input(): read an expression from the input file or standard input.
> however on reading the documentation I've found no mention of how
> to change the input to from a file. Also \r and "read" read the whole
> file at once which is not what I want. I would appreciate any help
> on how to do this,

Don't know how to do that in a simple way: we lack a FILE type for
incremental readings (or writings). The feature has priority 3/5 in the
TODO list.

(not really satisfactory) solutions:

1) put your integers into a vector (any decent text editor should do that
relatively easily)

2) \r in the whole file, then access the history entries [ e.g

  for (i=1, N, eval( Str("%" i) )

will loop through all entries %1 to %N

> and also the location of any more uptodate binaries
> for dos/windows!


Hope this helps,

Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathematiques, Bat. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas
PARI/GP Home Page: http://www.parigp-home.de/