Skip to content

Instantly share code, notes, and snippets.

(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
@w01fe
w01fe / fnk_examples.clj
Created October 2, 2012 00:43 — forked from aria42/fnk_examples.clj
Bring on the fnk
(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
(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?
(defmacro ->>
([x form] `(~@(if (seq form) form [form]) ~x))
([x form & more] `(->> (->> ~x ~form) ~@more)))