Permalink
Browse files

Clean up if-else tree with cond

  • Loading branch information...
1 parent 20b3a76 commit 10f95af33f1fb70eb3f424e98bbf0ff79a7baaf1 @selik committed Jul 13, 2014
Showing with 3 additions and 5 deletions.
  1. +3 −5 src/euler_clj/core.clj
@@ -53,11 +53,9 @@
(if (empty? multiples)
(found-prime)
(let [[factor smallest-multiple] (first multiples)]
- (if (< candidate smallest-multiple)
- (found-prime)
- (if (= candidate smallest-multiple)
- (found-composite factor)
- (catch-up-to-candidate factor)))))))))
+ (cond (< candidate smallest-multiple) (found-prime)
+ (= candidate smallest-multiple) (found-composite factor)
+ :else (catch-up-to-candidate factor))))))))
(defn primes
"Lazy sequence of prime numbers generated with Sieve of Eratosthenes"

0 comments on commit 10f95af

Please sign in to comment.