Re: [Jprogramming] indexing a table

2015-04-05 Thread Sergeif
Intresting! I have learned much more from this topic than I have in the last year with J. On Sun, Apr 5, 2015 at 8:12 PM, David Lambert wrote: > http://www.jsoftware.com/jwiki/Essays/Odometer > > Fastest of these is the sparse solution > (4 $. $.)@($&1) > > To fill your table assuming you've use

Re: [Jprogramming] indexing a table

2015-04-05 Thread Sergeif
Ouch! I'm sorry for incomplete specification, the full one is very very complex. I wasn't expecting to see a full solution. Ok, I'll try to simplify specification before starting to solve a problem. Anyway I got the point and this reply is really helpful, thank you again. On Sun, Apr 5, 2015 at 5:

Re: [Jprogramming] indexing a table

2015-04-05 Thread David Lambert
http://www.jsoftware.com/jwiki/Essays/Odometer Fastest of these is the sparse solution (4 $. $.)@($&1) To fill your table assuming you've used c notation: odometer =: (4 $. $.)@($&1) i=:{. j=:1&{ k=:{: ($ ([: ((i*j) - (i*k) - (j*k))"1 odometer))2 3 4 0 0 0 0 0 1 2 3 0 2 4

Re: [Jprogramming] indexing a table

2015-04-05 Thread Raul Miller
Why do you have recursive functions? Note that numbers themselves are recursive - most practical applications that "need recursive functions" can be redefined to instead "need functions with numeric domains". Put differently: a specification which specifies *how* something gets done will often be

Re: [Jprogramming] indexing a table

2015-04-05 Thread Sergeif
I'm not sure. May be I should use memoization instead. I have a bunch of recursive functions f,g,h,... defined like this: F(t,i,j,k) is a minimum of {C(i,j,k)+ sum of all g(t-1, i',j',k) + sum of all h(t-1, i, j", k') } and {F(t,i-1,j,k-1)+1}, where C -- user defined cost function, i' from 0 to i-

Re: [Jprogramming] indexing a table

2015-04-05 Thread Mike Day
Lots of replies already to your main question. As for "Another question is how to fill the table with values depending on indexes of cell? For example, F[i,j,k] = (i * j) - (i * k) + (j * k) ": As Henry says, you might not in practice need the whole index array; you also might not need to pop