Bill Allombert on Sat, 24 Mar 2018 20:46:45 +0100


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

New GP functions for file


Dear PARI developers,

we added a new function family for file operations:

fileclose    fileflush    fileread     filewrite
fileextern   fileopen     filereadstr  filewrite1

These functions emulate the FILE* C interface in GP.

to create a file with the power of 2 on separated lines:

n = fileopen("myfile","w");
for(i=1,10,filewrite(n,2^i));
fileclose(n)

to read a file line by line:

n = fileopen("myfile");
while (l = filereadstr(n), print(l))
fileclose(n)

to read "ls" output line by line:
n = fileextern("ls");
while (l = filereadstr(n), print(l))
fileclose(n)

Please test!

Cheers,
Bill and Karim