This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn filter-collecting [predicate collector & lists] | |
(lazy-seq | |
(loop [lists lists out []] | |
(if (empty? (first lists)) | |
(reverse out) | |
(let [heads (map first lists)] | |
(if (apply predicate heads) | |
(recur (map rest lists) (cons (apply collector heads) out)) | |
(recur (map rest lists) out))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn filter-collecting [predicate collector & lists] | |
(lazy-seq | |
(loop [lists lists out []] | |
(if (empty? (first lists)) | |
(reverse out) | |
(let [heads (map first lists)] | |
(if (apply predicate heads) | |
(recur (map rest lists) (cons (apply collector heads) out)) | |
(recur (map rest lists) out))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn filter-collecting [predicate collector & lists] | |
(lazy-seq | |
(loop [lists lists out []] | |
(if (empty? (first lists)) | |
(reverse out) | |
(let [heads (map first lists)] | |
(if (apply predicate heads) | |
(recur (map rest lists) (cons (apply collector heads) out)) | |
(recur (map rest lists) out))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn filter-collecting [predicate collector & lists] | |
(lazy-seq | |
(loop [lists lists out []] | |
(if (empty? (first lists)) | |
(reverse out) | |
(let [heads (map first lists)] | |
(if (apply predicate heads) | |
(recur (map rest lists) (cons (apply collector heads) out)) | |
(recur (map rest lists) out))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn filter-collecting [predicate collector & lists] | |
(lazy-seq | |
(loop [lists lists out []] | |
(if (empty? (first lists)) | |
(reverse out) | |
(let [heads (map first lists)] | |
(if (apply predicate heads) | |
(recur (map rest lists) (cons (apply collector heads) out)) | |
(recur (map rest lists) out))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; largest prime factor | |
(defn lpf | |
"Takes a number n and a starting number d > 1 | |
and calculates the largest prime factor of n | |
starting at number d. | |
usage: (lpf 364362978 2) => 8675309" | |
[n d] | |
(if (> d n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; largest prime factor | |
(defn lpf | |
"Takes a number n and a starting number d > 1 | |
and calculates the largest prime factor of n | |
starting at number d. | |
usage: (lpf 364362978 2) => 8675309" | |
[n d] | |
(if (> d n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; largest prime factor | |
(defn lpf | |
"Takes a number n and a starting number d > 1 | |
and calculates the largest prime factor of n | |
starting at number d. | |
usage: (lpf 364362978 2) => 8675309" | |
[n d] | |
(if (> d n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; largest prime factor | |
(defn lpf | |
"Takes a number n and a starting number d > 1 | |
and calculates the largest prime factor of n | |
starting at number d. | |
usage: (lpf 364362978 2) => 8675309" | |
[n d] | |
(if (> d n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; largest prime factor | |
(defn lpf | |
"Takes a number n and a starting number d > 1 | |
and calculates the largest prime factor of n | |
starting at number d. | |
usage: (lpf 364362978 2) => 8675309" | |
[n d] | |
(if (> d n) |