[Jprogramming] Memoizing (Project Euler problem 14)
Devon McCormick
devonmcc at gmail.com
Thu Aug 7 14:09:41 UTC 2014
Note that re-using one of the internal names gives a slight improvement in
space and a corresponding one in time:
c3=: 3 : 0
a=. 2|y
c=. 2+6*y
c=. a } y ,: c
(_1 & (33 b.)) c
)
100 ts 'c2 a'
0.0196169 2.62189e7
100 ts 'c3 a'
0.0170517 1.78303e7
Though I would normally rate these timings as basically the same since the
difference is relatively small.
On Thu, Aug 7, 2014 at 9:24 AM, Raul Miller <rauldmiller at gmail.com> wrote:
> That was my original impression.
>
> But then I looked at the right hand side of the expression:
>
> Why is it labelled x,y,:z and why does the text mention the case
> c}x,y,...,:z?
>
> It might be that this was originally a more ambitious project and that
> Roger got interrupted before he finished it.
>
> Anyways, it is interesting to me that the wiki page is silent about this
> explicitly documented issue.
>
> --
> Raul
>
>
>
> On Thu, Aug 7, 2014 at 8:53 AM, Henry Rich <HenryHRich at nc.rr.com> wrote:
>
> > 'boolean' here means that 3!:0 returns 1; the values are restricted to
> > {0,1}. Details at
> >
> > http://www.jsoftware.com/jwiki/Vocabulary/SpecialCombinations#
> > Assignments_In_Place_.28AIP.29
> >
> >
> > Henry Rich
> >
> >
> > On 8/7/2014 8:42 AM, Raul Miller wrote:
> >
> >> I think http://jsoftware.com/help/release/iamend.htm might be relevant.
> >>
> >> Note also that in this case I'm not sure if "boolean" really means
> >> "non-negative integer". (If I understand properly: in George Boole's
> >> arithmetic these were equivalent, and some of the details here suggest
> >> that
> >> that original meaning might be relevant here. It's a confusing topic
> >> though
> >> because it has become popular, depending on context, to assert that
> >> "boolean" can only refer to the values 0 and 1 and also that "boolean"
> >> cannot be used to refer to the values 0 and 1.)
> >>
> >> 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
>
--
Devon McCormick, CFA
More information about the Programming
mailing list