-
-
Notifications
You must be signed in to change notification settings - Fork 359
bubblesort in v #631
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
bubblesort in v #631
Conversation
berquist
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I missed this one.
You're missing the whole-file import in the chapter. Also, don't forget to revert the changes to book.json and .editorconfig now that they're already handled.
| arr := [1, 45, 756, 4569, 56, 3, 8, 5, -10, -4] | ||
| println('Array unsorted:') | ||
| println(arr) | ||
| bubblesort(mut arr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a compiler bug that you can mutate this here when it isn't mut arr above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no i think it is intentional that this works. but i don't think it's idiomatic. i will change that.
this one i wrote waaaay back when i first learned about vlang and when doing function(mut var) would actually create a faulty program
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that most of the bubble sort implementations mutate their input, if you declare mut arr := ..., I'll accept this.
contents/bubble_sort/bubble_sort.md
Outdated
| {% sample lang="bash" %} | ||
| [import:2-21, lang:"bash"](code/bash/bubble_sort.bash) | ||
| {% sample lang="v" %} | ||
| [import:2-21, lang:"v"](code/v/bubble_sort.v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your bounds aren't correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they probably aren't correct in any vlang pr 😓 will fix
I found a cool new language in the making called V. so yeah this is bubblesort in V.