[Jprogramming] Another newbie J question - generating a table
from a monadic function
Mikl Kurkov
mkurkov at gmail.com
Thu Jul 19 15:33:07 HKT 2007
Glenn M. Lewis wrote:
>
> fn =. 3 : 0
> +/(1+i.y)^5
> )
> fn 839
> 58340773411141200
>
> Now, I wish to make a table of all the values of 'fn' from 1 to
> 1000... Do I have to write a 'for' loop?
>
> Obviously, 'fn i. 1000' doesn't work and changing 'y' to "0 y in the
> function also doesn't work because of the '+/'.
>
Just use fn"0:
fn"0 >: i. 1000 NB. if you want calc fn values from 1 to 1000 you should
use >: i.1000, not just i.1000
But you can get the same result more effectively:
+/\(1+i.1000)^5
--
Mikl
--
View this message in context: http://www.nabble.com/Another-newbie-J-question---generating-a-table-from-a-monadic-function-tf4108474s24193.html#a11683752
Sent from the J Programming mailing list archive at Nabble.com.
More information about the Programming
mailing list