[Jprogramming] Another newbie J question - generating a table
from a monadic function
Rob Hodgkinson
rhodgkin at bigpond.net.au
Thu Jul 19 15:24:39 HKT 2007
Try making the function 'fn' itself scalar (rank 0) by either:
fn"(0) 3 5 839
276 4425 58340773411141200
Or else make the 'definition' rank 0 as follows:
fn =: 3 : 0 "0
+/(1+i.y)^5
)
fn 3 5 839
276 4425 58340773411141200
fn i.1000
...
.../Regards Rob
On 19/7/07 4:39 PM, "Glenn M. Lewis" <glenn at hometot.com> wrote:
> Hi all!
>
> Say I have a function, like so...
>
> 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 '+/'.
>
> This has got to be a simple thing, but I just can't quite seem to
> get it.
>
> Thanks!
> -- Glenn
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list