Skip to content

Instantly share code, notes, and snippets.

@w01fe
Created October 1, 2012 02:43
Show Gist options
  • Save w01fe/3809193 to your computer and use it in GitHub Desktop.
Save w01fe/3809193 to your computer and use it in GitHub Desktop.
Simple graph compilation
;; Functionally identical to (defn stats ...) above
(def stats (graph/eager-compile stats-graph))
(stats {:xs [1 2 3 6]})
; ==> {:n 4
; :m 3
; :m2 12.5
; :v 3.5)
;; Result is error checked
(stats {:ys [1 2 3 6]})
; ==> (Exception. "Missing argument :xs ...")
;; Compilation is error checked too.
(graph/eager-compile
{:x (fnk [y] (inc y))
:y (fnk [x] (dec x))})
; ==> (Exception. "Cannot compile cyclic graph
(:x --> :y --> :x)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment