Skip to content
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

Make code for sqrt examples actually run #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

O1O1O1O
Copy link

@O1O1O1O O1O1O1O commented Feb 1, 2018

The example code for sqrt didn't run when copy-pasted to a console.

This change uses math.abs and math.pow instead of just abs and square so it does.

@@ -33,7 +33,7 @@ object LexicalScopes extends ScalaTutorialSection {
* (guess + x / guess) / 2
*
* def isGoodEnough(guess: Double, x: Double) =
* abs(square(guess) - x) < 0.001
* math.abs(math.pow(guess, 2) - x) < 0.001
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would use guess * guess instead of math.pow(guess, 2)

@O1O1O1O
Copy link
Author

O1O1O1O commented Feb 1, 2018

Sorry, didn't realize you were going to approve as is. Amended with guess*guess and fixed another instance of the same problem.

@O1O1O1O O1O1O1O changed the title Use math.abs and math.pow so sqrt example runs Make code for sqrt examples actually run Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants