Skip to content

Added Bubblesort in Coconut #736

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

Merged
merged 5 commits into from
Oct 15, 2020

Conversation

Amaras
Copy link
Member

@Amaras Amaras commented Jul 17, 2020

Same as for Bogosort, I just slightly improved the Python code and removed the main function.
I opened those two PRs mainly to have them in Coconut, after thinking a bit about it.

(Also, I forgot to click the button, so that's why this one arrived late compared to the Bogosort one; I implemented them the same day)

for i in range(length):
for j in range(length - i - 1):
if array[j] > array[j + 1]:
array[j], array[j + 1] = array[j + 1], array[j]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see a full FP solution rather than a Python translation, even if it is one of the solutions in https://codereview.stackexchange.com/questions/197868/bubble-sort-in-haskell.



if __name__ == '__main__':
array = range(10) |> map$(-> random.randint(0, 1000)) |> list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure all the tabs are replaced with spaces and that your editor is set up to use the EditorConfig file.

@berquist berquist added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Jul 19, 2020
@Amaras
Copy link
Member Author

Amaras commented Jul 19, 2020

I was going to quit the functional style, but it seems it works quite well. Maybe not for huge lists, but close enough.
I could do an iterator sorting version if requested.

@Amaras Amaras requested a review from berquist July 19, 2020 17:28
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.

This is pretty wild. Thanks!

@berquist berquist merged commit 18944ea into algorithm-archivists:master Oct 15, 2020
@Amaras Amaras deleted the bubble_sort_coconut branch December 5, 2021 16:54
@Amaras Amaras restored the bubble_sort_coconut branch December 5, 2021 16:54
@Amaras Amaras deleted the bubble_sort_coconut branch December 5, 2021 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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