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
(defmacro ->> | |
([x form] `(~@(if (seq form) form [form]) ~x)) | |
([x form & more] `(->> (->> ~x ~form) ~@more))) |
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
(ns plumbing.graph-async | |
(:require | |
[plumbing.fnk.pfnk :as pfnk] | |
[plumbing.fnk.schema :as schema] | |
[plumbing.core :as plumbing] | |
[plumbing.graph :as graph])) | |
;; async function has ^:async metadata, callback required key. | |
;; TODO: redo with just promises/futures once they have callback options | |
;; TODO: make nicer way to specify async fnks? |
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
(defnk foo [x y [s 1]] | |
(+ x (* y s))) | |
(foo {:x 2 :y 3 :s 2}) | |
; ==> 8 | |
;; 's' defaults to 1 | |
(foo {:x 2 :y 3}) | |
; ==> 5 |
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
(def fib-var-obj | |
(fn [x] | |
(if (< x 2) | |
1 | |
(+ (fib-var-obj (- x 1)) | |
(fib-var-obj (- x 2)))))) | |
(defn fib-lex-obj [x] | |
(if (< x 2) | |
1 |