Skip to content

Modified euclidian algorithm haskell code to be more clear and readable #204

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 4 commits into from
Jul 3, 2018

Conversation

lulucca12
Copy link
Contributor

Avoided hiding values inside "where" bindings.

@lulucca12 lulucca12 changed the title Modified code to be more clear and readable Modified euclidian algorithm haskell code to be more clear and readable Jul 2, 2018
@Butt4cak3
Copy link
Contributor

Welcome to the AAA and thanks for your contribution!

In my opinion, your changes to this code are definitely improvements, especially those to euclidSub. There are a few people here who know Haskell better than me, though, so I'll leave the actual code review to them.

There is one thing you definitely have to change. When you look at the chapter you will notice that not the entire file is visible, but only the function the current paragraph is about. Since you changed quite a bit, you will have to adjust the line numbers in the code import. That's not too difficult.

Open euclidean.md in your editor and look for the code imports for Haskell. They look like this:

{% sample lang="haskell" %}
[import:3-11, lang="haskell"](code/haskell/euclidean_example.hs)

You will have to change that one to

{% sample lang="haskell" %}
[import:2-8, lang="haskell"](code/haskell/euclidean_example.hs)

because lines 2-8 contain euclidSub. I'm sure you will figure the rest out!

@Butt4cak3 Butt4cak3 requested review from zsparal and jiegillet July 2, 2018 17:23
@Butt4cak3 Butt4cak3 added the Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.) label Jul 2, 2018
@lulucca12
Copy link
Contributor Author

I've solved it now

@@ -53,7 +53,7 @@ Modern implementations, though, often use the modulus operator (%) like so
{% sample lang="py" %}
[import:1-9, lang="python"](code/python/euclidean_example.py)
{% sample lang="haskell" %}
[import:13-24, lang="haskell"](code/haskell/euclidean_example.hs)
[import:10-22, lang="haskell"](code/haskell/euclidean_example.hs)
Copy link
Contributor

@Butt4cak3 Butt4cak3 Jul 2, 2018

Choose a reason for hiding this comment

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

This should only import the euclidMod function without main. This was already wrong before you edited it, but if you look at all the other languages, you'll see that they all only import the one function. In other words, this should be 10-14.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, sorry 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

It's alright. As I said, it was wrong before you changed it, so no worries.

putStrLn (show chk1)
putStrLn (show chk2)
print chk1
print chk2
return ()
Copy link
Member

@jiegillet jiegillet Jul 3, 2018

Choose a reason for hiding this comment

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

print already returns IO (), is adding return () a thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since you already added the IO() in the type, you can omit it, I'll fix it

Copy link
Member

Choose a reason for hiding this comment

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

Again, I didn't write this :p (I wrote all other Haskell files though, I think)

@jiegillet jiegillet self-assigned this Jul 3, 2018
Copy link
Member

@jiegillet jiegillet left a comment

Choose a reason for hiding this comment

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

Nice improvements, thank you!

@jiegillet jiegillet merged commit 639bf75 into algorithm-archivists:master Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants