Skip to content

Commit 22d3182

Browse files
committed
[exercise] 4.8
1 parent 60f63c1 commit 22d3182

File tree

1 file changed

+9
-0
lines changed
  • chapter04-Defining-functions

1 file changed

+9
-0
lines changed

chapter04-Defining-functions/8.hs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
luhnDouble :: Int -> Int
2+
luhnDouble n | d > 9 = d - 9
3+
| otherwise = d
4+
where d = n * 2
5+
6+
luhn :: Int -> Int -> Int -> Int -> Bool
7+
luhn n1 n2 n3 n4 | sum `mod` 10 == 0 = True
8+
| otherwise = False
9+
where sum = luhnDouble n1 + n2 + luhnDouble n3 + n4

0 commit comments

Comments
 (0)