Skip to content

Instantly share code, notes, and snippets.

@aria42
aria42 / fnk_examples.clj
Created October 1, 2012 21:29 — forked from w01fe/fnk_examples.clj
Bring on the fnk
(defnk foo [x y [s 1]]
(+ x (* y s)))
(foo {:x 2 :y 3 :s 2})
;; ==> 8
(foo {:x 2 :y 3})
;; 's' defaulted to 1
;; ==> 5
root (-> (dp/poller-graph s)
(add-edge (fn [x]
(log/info (format "Finished an entry %s has body: %s"
(-> x :entry :link) (not (nil? (-> x :entry :body)))))))
zip/root graph-zip zip/down zip-down ; Move to feed-fetch-node
(add-edge (fn [{k :key b :body}]
(let [es (set (feeds/extract-entries b))]
(swap! fetched-feeds conj k)
(swap! extracted-entries set/union es)
(log/info (format "Added %d entries from %s." (count es) k))))))