On 3/20/07, Barton Willis <willisb at unk.edu> wrote:
> (%i1) load(numericalio)$
> (%i2) f(x) := exp(x)$
> (%i3) data : make_array ('any,10,2)$
> (%i4) x : 0.0$
> (%i5) for i : 0 thru 9 do (data[i,0] : x, data[i,1] : f(x), x : x + 0.1)$
> (%i6) write_data(data, "c:/my_data.txt");
> (%o6) done
I guess opinions will vary, but the following seems more idiomatic to me ....
expr : exp(x) + sin(x); /* or whatever */
xx : makelist (i/10.0, i, 0, 100);
yy : map (lambda ([x], ev (expr)), xx);
M : transpose (matrix (xx, yy));
load (numericalio);
write_data (M, "/tmp/foo.data");
makelist and map replace the for-loop, and the matrix replaces the array.
These are somewhat subtle points and probably it works OK either way.
Doubtless there are still other workable variations.
HTH
Robert