Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typo in vectorMultiply example of getting started document #36

Open
timsherwood opened this issue Aug 27, 2017 · 1 comment
Open

typo in vectorMultiply example of getting started document #36

timsherwood opened this issue Aug 27, 2017 · 1 comment

Comments

@timsherwood
Copy link

Minor bug in getting started document at start of Section 2.2 Arrays, in the code:

function vectorMultiply(int[] vector, int[] scalar) -> int[]:
    int i = 0
    while i < |vector|:  // needs loop invariant
        vector[i] = vector[i] * scalar
        i = i + 1
    return vector

Scalar is defined as an array (which I assume is just a typo). I would also mention that this code does not compile even with that fixed without the loop invariant i>=0 (unless I am doing something wrong) but perhaps that is intentional (to avoid getting into that discussion so early in the document). If you are not looking yet for such trivial errors given your other work, please just ignore. :)

Really enjoying playing with this language, thanks for making it so accessible!

-Tim ([email protected])

@DavePearce
Copy link
Member

DavePearce commented Aug 31, 2017

Hey Tim,

Thanks for pointing out the typo. Looks like I already fixed in the repository, but have not uploaded the updated PDF. Not sure why I hadn't done that --- so thanks. Fixed now.

Glad you're enjoying playing with the language. To be fair, I think I've got a lot to do yet to make it more accessible :) Are you using the online IDE? So, this version of the loop does verify in http://whileylabs.com right now:

function vectorMultiply(int[] vector, int scalar) -> int[]:
    int i = 0
    while i < |vector| where i >= 0:  // needs loop invariant
        vector[i] = vector[i] * scalar
        i = i + 1
    return vector

Is that roughly what you had? Was it on whileylabs that it was failing or somewhere else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants