[CLOSED] ++ add is wrong #11

Closed
philipcmonk opened this Issue Aug 29, 2014 · 6 comments

Comments

Projects
None yet
1 participant
Contributor

philipcmonk commented Aug 29, 2014

Issue by johncburnham
Wednesday Aug 28, 2013 at 18:49 GMT
Originally opened as urbit/archaeology#11


++ add :: add
~/ %add
|= [a=@ b=@]
^- @
?: =(0 a)
b
$(a (dec a), b +(b))

should be

++ add :: add
~/ %add
|= [a=@ b=@]
=+ c=0
|- ^- @
?: =(c a)
b
$(c +(c), b +(b))

and then change the doc here http://urbit.github.io/2013/08/22/Chapter-0-intro.html.

Add should be O(n) not O(n^2).

Contributor

philipcmonk commented Aug 29, 2014

Comment by twopir
Monday Oct 07, 2013 at 02:55 GMT


I'm willing to make this change, but I don't know how this makes add O(n) instead of n^2.

Contributor

philipcmonk commented Aug 29, 2014

Comment by twopir
Monday Oct 07, 2013 at 02:56 GMT


Oh, wait, I think I see it now. Introduce an accumulator "c" and don't go into dec?

philipcmonk added this to the Gen190 milestone Aug 29, 2014

Contributor

philipcmonk commented Aug 29, 2014

Comment by philipcmonk
Monday Oct 07, 2013 at 02:58 GMT


Exactly.

Philip Monk

On Sun, Oct 6, 2013 at 7:56 PM, Eugene Belford notifications@github.comwrote:

Oh, wait, I think I see it now. Introduce an accumulator "c" and don't go
into dec?


Reply to this email directly or view it on GitHubhttps://github.com/urbit/urbit/issues/11#issuecomment-25782940
.

Contributor

philipcmonk commented Aug 29, 2014

Comment by johncburnham
Monday Oct 07, 2013 at 03:02 GMT


we're holding off on doing this for now because:
a. it literally makes no difference (because it gets jet-propelled anyway)
b. we still have to test the change, and there are higher-priority things for us to be doing.

One of these days our intrepid band of nascent hoon programmers will go through and optimize all this stuff. Not because it makes any practical difference, but because it's just aesthetically nice to have functions be as clean and simple as possible.

Contributor

philipcmonk commented Aug 29, 2014

Comment by twopir
Monday Oct 07, 2013 at 03:06 GMT


That and some of us are sticklers for "correctness". I'll come back to this unless someone else knocks it out first.

Contributor

philipcmonk commented Aug 29, 2014

Comment by ikbrunel
Monday Oct 07, 2013 at 04:29 GMT


I just got an image of a Hoon dojo with a cohort of initiates writing test
suites for each others' Nock interpreters.

Katas on the mind...

On Oct 6, 2013, at 8:02 PM, johncburnham notifications@github.com wrote:

we're holding off on doing this for now because:
a. it literally makes no difference (because it gets jet-propelled anyway)
b. we still have to test the change, and there are higher-priority things
for us to be doing.

One of these days our intrepid band of nascent hoon programmers will go
through and optimize all this stuff. Not because it makes any practical
difference, but because it's just aesthetically nice to have functions be
as clean and simple as possible.


Reply to this email directly or view it on
GitHubhttps://github.com/urbit/urbit/issues/11#issuecomment-25783045
.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment