At 14:43  -0400 2007/06/19, Lewis, Glenn wrote:

   diagonals 0

1 1 1 1

   diagonals 1

9 7 5 3

   diagonals 2

25 21 17 13



   But if I try to get all diagonals from the first 10 rings of the
spiral, I get:



   diagonals i. 10

|length error: diagonals

|   t2=.0 2 4 6    *y



   I understand what the problem is (the length mismatch), but don't
know how to fix it...  I need to take each scalar in y one-at-a-time...
and I tried all sorts of combinations of " (double quote) to treat the
right hand side like a rank 0 input, but couldn't get it to work.



            Any ideas?


   diagonals "0 i. 10
  1   1   1   1
  9   7   5   3
 25  21  17  13
 49  43  37  31
 81  73  65  57
121 111 101  91
169 157 145 133
225 211 197 183
289 273 257 241
361 343 325 307

Seems to work well, that is making diagonals rank 0, you could
do that when defining it, thus -

   diagonals =: 3 : 0 "0
t1 =. 4 $ brds y
t2 =. 0 2 4 6 * y
t1 - t2
)
   diagonals i. 10
  1   1   1   1
  9   7   5   3
 25  21  17  13
 49  43  37  31
 81  73  65  57
121 111 101  91
169 157 145 133
225 211 197 183
289 273 257 241
361 343 325 307

- joey

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

Reply via email to