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

Ch4 isEven compatibility with negative inputs #339

Merged
merged 2 commits into from
May 18, 2021

Conversation

milesfrain
Copy link
Member

Fixes #327

@milesfrain milesfrain changed the title Ch3 isEven compatibility with negative inputs Ch4 isEven compatibility with negative inputs May 16, 2021
Comment on lines 16 to 21
isEven n =
if n == 0
then true
else if n < 0
then isEven (-n)
else not (isEven (n - 1))
Copy link

Choose a reason for hiding this comment

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

Deal with sign first?

isEven n =
  if n < 0
    then isEven (-n)
    else if n == 0
      then true
      else not (isEven (n - 1))

Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes it's nice to start with the base cases first, but I have no strong feelings either way. Applied your suggestion.

@milesfrain milesfrain merged commit 8abb4d8 into purescript-contrib:master May 18, 2021
@milesfrain milesfrain deleted the even-neg branch May 18, 2021 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Ch4 isEven exercise does not mention sign
2 participants