Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

redule expressions

  • Loading branch information...
commit 39f351b8c9fc0cebbd05c7880190fb73122b6bdb 1 parent 6dc845e
@youknowone authored
Showing with 10 additions and 10 deletions.
  1. +3 −3 euler001.hs
  2. +3 −3 euler002.hs
  3. +4 −4 euler003.hs
View
6 euler001.hs
@@ -1,9 +1,9 @@
-sum3_5 n = [x|x <- [1..], mod x 3 == 0 || mod x 5 == 0] `sum_to` n
+sum3_5 n = sum_to [x|x <- [1..], mod x 3 == 0 || mod x 5 == 0]
where
- sum_to (x:xs) n
+ sum_to (x:xs)
| x >= n = 0
- | otherwise = x + (xs `sum_to` n)
+ | otherwise = x + (sum_to xs)
main = do
print $ sum3_5 1000
View
6 euler002.hs
@@ -1,9 +1,9 @@
-fib_sum n = fib_sum_inner n [1,0]
+fib_sum n = fib_sum_inner [1,0]
where
- fib_sum_inner n s@(x1:x2:xs)
+ fib_sum_inner s@(x1:x2:xs)
| x > n = 0
- | otherwise = even_value x + fib_sum_inner n (x:s)
+ | otherwise = even_value x + fib_sum_inner (x:s)
where
x = x1 + x2
even_value n = if even n then n else 0
View
8 euler003.hs
@@ -5,13 +5,13 @@ primes = primes_inner [] [2 ..]
factors n
| n < 2 = [n]
- | otherwise = factors_inner n n [] primes
+ | otherwise = factors_inner n [] primes
where
- factors_inner value remain facts prms@(p:ps)
+ factors_inner remain facts px@(p:ps)
| remain == 1 = facts
| p * p > n = remain:facts
- | remain `mod` p == 0 = factors_inner value (remain `div` p) (p:facts) prms
- | otherwise = factors_inner value remain facts ps
+ | remain `mod` p == 0 = factors_inner (remain `div` p) (p:facts) px
+ | otherwise = factors_inner remain facts ps
main = do
Please sign in to comment.
Something went wrong with that request. Please try again.