These are less than a factor of two different, and on my system noise in timing can swamp any computational difference, despite the size issues:
ts'~.;<@(*{.)\.>:i.1000' 0.0176966 1.49499e7 ts'~.,*/~>:i.1000' 0.0174547 2.62336e7 But that size difference might be worth worrying about in extreme cases. I imagine that the time difference might be more stable on larger arguments, and might favor the shorter expression on smaller arguments. -- Raul On Mon, Jun 25, 2012 at 1:06 PM, R.E. Boss <r.e.b...@planet.nl> wrote: > > ts'~.;<@(*{.)\.>:i.1000' > 0.0072987262 14949888 > > ts'~.,*/~>:i.1000' > 0.011011744 26233600 > > (~.,*/~>:i.1000)-:~.;<@(*{.)\.>:i.1000 > 1 > > > R.E. Boss > > >> -----Oorspronkelijk bericht----- >> Van: programming-boun...@jsoftware.com >> [mailto:programming-boun...@jsoftware.com] Namens R.E. Boss >> Verzonden: maandag 25 juni 2012 18:57 >> Aan: 'Programming forum' >> Onderwerp: Re: [Jprogramming] Multiplying with folds >> >> >> ;<@(*{.)\.>:i.5 >> 1 2 3 4 5 4 6 8 10 9 12 15 16 20 25 >> >> >> ~.,*/~>:i.5 >> 1 2 3 4 5 6 8 10 9 12 15 16 20 25 >> >> >> R.E. Boss >> >> >> > -----Oorspronkelijk bericht----- >> > Van: programming-boun...@jsoftware.com >> > [mailto:programming-boun...@jsoftware.com] Namens Raul Miller >> > Verzonden: maandag 25 juni 2012 18:51 >> > Aan: Programming forum >> > Onderwerp: Re: [Jprogramming] Multiplying with folds >> > >> > Why do you want this? >> > >> > If it's efficiency, note that the size of the dense array */~N is >> > typically less than the size of a linked list which only represents >> > the products of unique combinations of pairs (if we assume that linked >> > list pointer size is approximately the same size as a number), and >> > also note that typical cpu cache implementation heavily favors regular >> > operations. >> > >> > If it's because you need unique values, you might consider using: >> > >> > ~.,*/N >> > >> > If it's for some other purpose, the topic might have inherent interest... >> > >> > Thanks, >> > >> > -- >> > Raul >> > >> > On Mon, Jun 25, 2012 at 12:37 PM, David Vaughan <purpleblue...@gmail.com> >> > wrote: >> > > I'm looking for a verb to achieve the same thing as just the unique items >> > > of */~ N, i.e. n0*(n0 ... nk) n1*(n1 ... nk) n2*(n2 ... nk) ... nk*nk. >> > > >> > > I can easily create the result, but I want to be able to calculate it >> > > more >> > > efficiently, without having to do the multiplications that will >> > > ultimately >> > > be redundant (which would be ~.,*/~ N). >> > > >> > > I'm not particularly good with folds and similar concepts, so I expect >> > > the >> > > solution is relatively simple. Can anyone help? >> > > >> > > Many thanks. >> > > ---------------------------------------------------------------------- >> > > 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