Skip to content

Conversation

@Liikt
Copy link

@Liikt Liikt commented Oct 2, 2019

I found a cool new language in the making called V. so yeah this is bubblesort in V.

@Liikt Liikt added Hacktoberfest The label for all Hacktoberfest related things! Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) labels Oct 2, 2019
Copy link
Member

@berquist berquist left a 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)
Copy link
Member

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.

Copy link
Author

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

Copy link
Member

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.

{% 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)
Copy link
Member

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.

Copy link
Author

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

@berquist berquist changed the title add vlang and bubblesort in v bubblesort in v Oct 27, 2019
@berquist berquist merged commit 1a4583b into algorithm-archivists:master Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hacktoberfest The label for all Hacktoberfest related things! Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants