Skip to content

Commit

Permalink
πŸ› fix negative
Browse files Browse the repository at this point in the history
  • Loading branch information
CypressVillage committed Jan 25, 2024
1 parent 286780e commit c57a80e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Chapter1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ Implement a function that returns the last digit of a given number.
-}
-- DON'T FORGET TO SPECIFY THE TYPE IN HERE
lastDigit :: Int -> Int
lastDigit n = n `mod` 10
lastDigit = (`mod` 10) . abs


{- |
Expand Down Expand Up @@ -641,8 +641,9 @@ specifying complex expressions.

sumLast2 :: Int -> Int
sumLast2 x =
let last = x `mod` 10
secondlast = x `mod` 100 `div` 10
let ax = abs x
last = ax `mod` 10

Check warning on line 645 in src/Chapter1.hs

View workflow job for this annotation

GitHub Actions / Chapter One (3.8, 9.4.4)

This binding for β€˜last’ shadows the existing binding

Check warning on line 645 in src/Chapter1.hs

View workflow job for this annotation

GitHub Actions / Build Learn4Haskell (3.8, 9.4.4)

This binding for β€˜last’ shadows the existing binding
secondlast = ax `mod` 100 `div` 10
in last + secondlast


Expand Down

0 comments on commit c57a80e

Please sign in to comment.