+/@:f@:i.  is an infinite class and  t.  does not recognize all members 
of the class.  It could conceivably do  +/@:(m&p.)@:i.  but it has to
stop somewhere. 

   +/@:%@:p: @:i.
   +/@:%@:fib@:i.   NB. open problem




----- Original Message ----- 
From: "Paul" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 03, 2006 10:53 PM
Subject: [Jprogramming] K. E. Iverson's Math for the Layman, section 
11E,exercise 3

   9!:14 ''
j504/2005-03-30/13:35

   +/@i. t. i.4
0 _1r2 1r2 0

So, J knows that

   NB. for n integer > 0
   (+/ i. n) = (n*(n-1))%2
   (+/ i. n) = (_1r2*n) + 1r2*n*n
   (+/ i. n) = (0 _1r2 1r2 0 p. n)


Then why not 

   n=: 6

   f =: +/ @: (2: * i.) NB. sum of first n even numbers (starting at 0)
   f n NB. n*n-1
30
   f t. i.4
|domain error
|       f t.i.4

   g =: +/ @: (1: + 2: * i.) NB. sum of first n odd numbers
   g n NB.  n*n
36
   g t. i.4
|domain error
|       g t.i.4
   
   h =: +/ @: *: @: i. NB. sum of square of first n numbers (starting at 0)
   h n
55
   h t. i.5 NB. probably a third degree polynomial
|domain error
|       h t.i.5
   
What am I doing wrong? Are the functions f g and h defined in a way that is 
not acceptable to t. ?


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to