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-1, j' and j" from zero to j-1, k' from 0 to k-j. I'm intrested in a value of F(T,N,M,K) for some T,N,M,K ≤ 1000. A common pattern for tasks like this would be very helpful for me. 04 апр. 2015 г. 23:50 пользователь "Henry Rich" <henryhr...@nc.rr.com> написал: > It's unusual in J to need the full odometer array. Are you sure that your > problem requires it? > > Henry rich > > On 4/4/2015 5:48 PM, Sergeif wrote: > >> Thanks! It's 10x faster than my code but 10x slower than odometer >> function. >> Anyway I lernt the catalogue verb from this. >> >> On Sat, Apr 4, 2015 at 11:21 PM, R.E. Boss <r.e.b...@outlook.com> wrote: >> >> >>> >,{<@i."0[2 3 4 >>> 0 0 0 >>> 0 0 1 >>> 0 0 2 >>> 0 0 3 >>> 0 1 0 >>> 0 1 1 >>> 0 1 2 >>> 0 1 3 >>> 0 2 0 >>> 0 2 1 >>> 0 2 2 >>> 0 2 3 >>> 1 0 0 >>> 1 0 1 >>> 1 0 2 >>> 1 0 3 >>> 1 1 0 >>> 1 1 1 >>> 1 1 2 >>> 1 1 3 >>> 1 2 0 >>> 1 2 1 >>> 1 2 2 >>> 1 2 3 >>> >>> R.E. Boss >>> >>> >>> -----Original Message----- >>>> From: programming-boun...@forums.jsoftware.com [mailto:programming- >>>> boun...@forums.jsoftware.com] On Behalf Of Nollaig MacKenzie >>>> Sent: zaterdag 4 april 2015 23:16 >>>> To: programm...@jsoftware.com >>>> Subject: Re: [Jprogramming] indexing a table >>>> >>>> Is something like this what you have in mind? >>>> >>>> m=. i. 2 3 4 >>>> indmak m >>>> 0 0 0 >>>> 0 0 1 >>>> 0 0 2 >>>> 0 0 3 >>>> >>>> 0 1 0 >>>> 0 1 1 >>>> 0 1 2 >>>> 0 1 3 >>>> >>>> 0 2 0 >>>> 0 2 1 >>>> 0 2 2 >>>> 0 2 3 >>>> >>>> >>>> 1 0 0 >>>> 1 0 1 >>>> 1 0 2 >>>> 1 0 3 >>>> >>>> 1 1 0 >>>> 1 1 1 >>>> 1 1 2 >>>> 1 1 3 >>>> >>>> 1 2 0 >>>> 1 2 1 >>>> 1 2 2 >>>> 1 2 3 >>>> indmak >>>> (#: i.)@$ >>>> >>>> >>>> On 2015.04.04 23:09:58, you, >>>> the extraordinary Sergeif, spake thus: >>>> >>>> Hi. >>>>> >>>>> How can someone create list of indexes of 3d table (N x M x K)? >>>>> >>>>> I have written this simple code: >>>>> >>>>> ind3d =: 3 : 0 >>>>> 'n m k' =. y >>>>> p0 =. k&| >>>>> p1 =. (m&|)@:<.@:(%&k) >>>>> p2 =. <.@:(%&(m*k)) >>>>> (p2 , p1 , p0)"0 (i. (n*m*k)) >>>>> ) >>>>> >>>>> but it's very very slow. Does any tacit solution for this problem >>>>> >>>> exist? >>> >>>> >>>>> 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). >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see >>>>> >>>> http://www.jsoftware.com/forums.htm >>>> >>>> -- >>>> Nollaig MacKenzie >>>> http://www.yorku.ca/nollaig >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >>> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> >> ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm