[bknr-cvs] hans changed trunk/projects/planetwit/planetwit.clj
BKNR Commits
bknr at bknr.net
Thu Aug 20 00:56:02 UTC 2009
Revision: 4443
Author: hans
URL: http://bknr.net/trac/changeset/4443
clarify code by using filter instead of hand-written recursive loop
U trunk/projects/planetwit/planetwit.clj
Modified: trunk/projects/planetwit/planetwit.clj
===================================================================
--- trunk/projects/planetwit/planetwit.clj 2009-08-19 19:50:49 UTC (rev 4442)
+++ trunk/projects/planetwit/planetwit.clj 2009-08-20 00:56:01 UTC (rev 4443)
@@ -57,24 +57,13 @@
(defn poll
"Poll planet lisp, check for new postings, update Twitter status when new postings have appeared"
[]
- (save-data
(let [old-urls (load-data)
- process (fn [items all-items new-items]
- (if items
- (let [item (first items)
- guid (:guid item)
- title (:title item)]
- (recur (rest items)
- (conj all-items item)
- (if (old-urls guid)
- new-items
- (conj new-items item))))
- (do
- (post-twits new-items)
- (into #{} (map #(:guid %) all-items)))))]
- (process (map (fn [item]
- {:guid (first (xml-> item :guid text))
- :title (first (xml-> item :title text))})
- (xml-> (feed-to-zip "http://planet.lisp.org/rss20.xml")
- :channel :item))
- nil nil))))
+ all-items (map (fn [item]
+ {:guid (first (xml-> item :guid text))
+ :title (first (xml-> item :title text))})
+ (xml-> (feed-to-zip "http://planet.lisp.org/rss20.xml")
+ :channel :item))
+ new-items (filter (complement #(old-urls (:guid %))) all-items)]
+ (post-twits new-items)
+ (save-data (into #{} (map #(:guid %) all-items)))))
+
More information about the Bknr-cvs
mailing list