[Maxima] Package NumericalIO

Robert Dodier robert.dodier at gmail.com
Mon May 21 20:38:35 CDT 2012


On 2012-05-18, Evgeniy Maevskiy <emaevskiy at e-math.ru> wrote:

> 1) ... to rewrite function read_list and others for reading list (array, 
> matrix) of expressions (not only of numbers).

That's an interesting idea. It is assumed in the numericalio package
that data files comprise Maxima parser tokens, that is, elements such as
numbers, strings, and symbols. Such files are, often enough, not valid
as expressions, e.g. 1 2 3 4. 

Now that you mention it, I guess the separator flag could be repurposed
(generally a clumsy thing to do; oh well) to designate a data file of
expressions. E.g. something like read_list("foo.data", 'expressions) to
read whole expressions instead of one token at a time. It would require
some minor work in share/numericalio/numericalio.lisp.

> 2) ... to add some functions for write and read arbitrary text-file, for 
> example:
>
> (defun $fwrite (f &rest c)
>      (with-open-file (stream f :direction :output)
>          (loop for s in c
>              do (write-line s stream))))
>
> Usage:
>
> fwrite("D:/Compmath/temp_file.txt",
>      "a string",
>      "another string",
>      "again another string"
> )$

Well, you can already get this effect via the existing functions
opena and/or openw, and printf. E.g.:

fwrite (fname, [lines]) := block ([S : openw (fname)],
  for l in lines do printf (S, "~a~%", l),
  close (S));

best

Robert Dodier



More information about the Maxima mailing list