Jamie Mulholland <j_mulholl...@sfu.ca> 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 <calcp...@aol.com> 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 in range(1,10)]
>
> These methods work fine. I'm confused on how to write function for
> a(n) where I can just input a list, process the list and output a new
> list with the sequence evaluated.
>
> So, if a(n)=n**2 and the input is [1,2,3] the output should be
> [1,4,9].
>
> TIA,
> A. Jorge Garcia
> http://shadowfaxrant.blogspot.com
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-edu" group.
> To post to this group, send email to sage-edu@googlegroups.com.
> To unsubscribe from this group, send email to 
> sage-edu+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sage-edu?hl=en.
>
>



-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jamie Mulholland, Ph. D.            e: j_mulholl...@sfu.ca
Dept. of Mathematics                  t:  778-782-7655
Simon Fraser University              f:  778-782-4947
8888 University Drive
Burnaby, B.C. V5A 1S6
Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com.
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en.


Sorry, what I meant to say was: what if I define a function such as
def a(n):
return 1/n**2
so running
a([2,4,6])
yields
[1/4,1/16,1/36]
Thanx,
A. Jorge Garcia
Applied Math and CompSci
http://shadowfaxrant.blogspot.com
http://www.youtube.com/calcpage2009
Sent via DROID on Verizon Wireless

-- 
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com.
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en.

Reply via email to