JoshOrndorff / librho

A Standard Library for Rholang
Apache License 2.0
12 stars 6 forks source link

Given a list of integers, this contract returns the sum #4

Open Eknir opened 5 years ago

Eknir commented 5 years ago

Refactoring by making separate type-checking contracts and including them here would perhaps be a good idea.

JoshOrndorff commented 5 years ago

Could I talk you into using two spaces instead of tabs?

Eknir commented 5 years ago

Yes, you can. I will use that from now one. Thanks for the pointer :). What do you think besides this? Is it a useful addition to the library like this, or do you think more refactoring (i.e. type-checking, iterating) is needed?

Op do 18 okt. 2018 om 21:13 schreef Joshy Orndorff <notifications@github.com

:

Could I talk you into using two spaces instead of tabs?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JoshOrndorff/librho/pull/4#issuecomment-431126508, or mute the thread https://github.com/notifications/unsubscribe-auth/AfeL-a0XUOueJpgVaRRZNst1Uil7qxKbks5umNLTgaJpZM4XtddE .

JoshOrndorff commented 5 years ago

I think definitely think it is useful as is. I might rename to sumList or something short like that. You might also consider generalizing the pattern slightly to be more of a foldLeft. I'd happily merge it as ssumList though.

Eknir commented 5 years ago

I proposed a change which includes changing the name to SsumList. When I have time I will look at the foldLeft pattern and make all tabs two spaces

On Fri, 19 Oct 2018, 05:53 Joshy Orndorff, notifications@github.com wrote:

I think definitely think it is useful as is. I might rename to sumList or something short like that. You might also consider generalizing the pattern slightly to be more of a foldLeft. I'd happily merge it as ssumList though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JoshOrndorff/librho/pull/4#issuecomment-431236931, or mute the thread https://github.com/notifications/unsubscribe-auth/AfeL-VnzuADpKl3rubQk22lwSur2kzWRks5umUy0gaJpZM4XtddE .

ddayan commented 5 years ago

Just realised this was submitted a while ago I'm happy to do the changes I requested if @Eknir is busy

ddayan commented 5 years ago
    // Integration tests
    new stdout(`rho:io:stdout`) in {
        new myReturn, myError in {
      getSumFromList!([1,2,3], *myError, *myReturn) | for(@return <- myReturn) { 
          stdout!([return, "Expected: 6"]) 
        }
        }
        |
        new myReturn, myError in {
        getSumFromList!([1], *myError, *myReturn) | { for(@return <- myReturn) {
            stdout!([return, "Expected: 1"]) 
        }
        }
        |
        new myReturn, myError in {
        getSumFromList!("Hello", *myError, *myReturn) | for(@error <- myError) {
            stdout!([error, "Expected: {Error: Sent process does not match [hd, ...tl], Item: Hello}"]) 
        }
        }
        |
        new myReturn, myError in {
        getSumFromList!([1, "Hello", 2], *myError, *myReturn) | for(@error <- myError) {
            stdout!([error, "Expected: {Error: List contained non-integer, Item: Hello}"])
        }
        }
    }
JoshOrndorff commented 5 years ago

@ddayan Yeah, please make the changes if you're still feeling it. I'll merge. I like your comment about running tests in parallel.