-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Added Bubblesort in Coconut #736
Conversation
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] |
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.
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 |
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.
Make sure all the tabs are replaced with spaces and that your editor is set up to use the EditorConfig file.
I was going to quit the functional style, but it seems it works quite well. Maybe not for huge lists, but close enough. |
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.
This is pretty wild. Thanks!
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)