A word to the wise ... if you want helpful advice on this list, it is best
to describe (ideally with an example) the *result* you want, not the method
you think you want to use. Your question was "use 'for' loop to create
list...". But in fact 'for' loops were not the issue.
-s
On Tue, Apr 3, 2012 at 08:35, Ether Jones <maxima at etherjones.us> wrote:
> .
> Thanks. That's a whole lot easier than the way I was trying to do it:
>
> n: 10$
> f(x):=x^2;
> h[i,j] := i$
> MX: genmatrix (h,n,1)$
> k[i,j] := i^(j+1)$
> MY: genmatrix (k,n,1)$
> X: list_matrix_entries(MX);
> Y: list_matrix_entries(MY);
> plot2d([discrete,X,Y]);
>
> I still haven't figured out how to effectively search the Maxima help. If
> you don't know the word you're searching for (in this case "makelist"),
> sometimes it's hard to find what you need.
> .
>
>
> ------------------------------
> *From:* Richard Fateman <fateman at eecs.berkeley.edu>
> *To:* Ether Jones <maxima at etherjones.us>
> *Sent:* Tuesday, April 3, 2012 10:19 AM
>
> *Subject:* Re: [Maxima] use "for" loop to create list
>
> On 4/3/2012 7:09 AM, Ether Jones wrote:
>
> How do I create this list:
>
> f(x):=x^2;
>
> myList: [
> [1, f(1)],
> [2, f(2)],
>
> ...
>
> mylist: makelist([i,i^2],i,1,10)
>
> or if you insist on a " for loop ',
>
> s:[],
> for i:1 thru 10 do s:cons([i,i^2],s),
> mylist: reverse(s),
> ...
>
> I had suggested (and, I think, implemented) a change to allow
>
> mylist: for i:1 thru 10 collect [i,i^2];
>
> but that somehow didn't happen.
>
> The common lisp "loop" could be used as an inspiration for other
> extensions.
>
> RJF
>
>
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>