Re: [sage-edu] sequences

2011-11-03 Thread A. Jorge Garcia
michel paul wrote: You could use *n for your parameter. It allows you to enter an arbitrary number of arguments: def a(*n): return [1/k^2 for k in n] a(2,4,6) ---> [1/4,1/16,1/36] a(5) ---> [1/25] Not exactly what you were wanting, but pretty close. But - why not just go ahead and define

Re: [sage-edu] sequences

2011-11-03 Thread michel paul
You could use *n for your parameter. It allows you to enter an arbitrary number of arguments: def a(*n): return [1/k^2 for k in n] a(2,4,6) ---> [1/4,1/16,1/36] a(5) ---> [1/25] Not exactly what you were wanting, but pretty close. But - why *not* just go ahead and define a(n) for the nth term

Re: [sage-edu] sequences

2011-11-02 Thread A. Jorge Garcia
Jamie Mulholland wrote: Could use the map command: sage: a(n)=n^2 sage: map(a,[1,2,3]) [1,4,9] Cheers Jamie On Wed, Nov 2, 2011 at 9:52 AM, A. Jorge Garcia wrote: > My discrete math class was playing with sequences today. > > Example 1) > a(n)=1/n**2 > for I in range(1,10): >show(a(I)) >

Re: [sage-edu] sequences

2011-11-02 Thread Jason Grout
On 11/2/11 12:16 PM, Jamie Mulholland wrote: Could use the map command: sage: a(n)=n^2 sage: map(a,[1,2,3]) [1,4,9] Or list comprehensions: [n^2 for n in [1,2,3]] or [a(n) for n in [1,2,3]] -Jason -- You received this message because you are subscribed to the Google Groups "sage-edu" gr

Re: [sage-edu] sequences

2011-11-02 Thread Jamie Mulholland
Could use the map command: sage: a(n)=n^2 sage: map(a,[1,2,3]) [1,4,9] Cheers Jamie On Wed, Nov 2, 2011 at 9:52 AM, A. Jorge Garcia wrote: > My discrete math class was playing with sequences today. > > Example 1) > a(n)=1/n**2 > for I in range(1,10): >    show(a(I)) > > Example 2) > [a(n) for I