Skip to content

Instantly share code, notes, and snippets.

@christianromney
Forked from ddeaguiar/gist:3889008
Created October 14, 2012 16:08
Show Gist options
  • Select an option

  • Save christianromney/3889040 to your computer and use it in GitHub Desktop.

Select an option

Save christianromney/3889040 to your computer and use it in GitHub Desktop.
One way to identify neighbors
(ns simple-csp.core)
(def arcs [
#{:sa :wa}
#{:sa :nt}
#{:sa :q}
#{:sa :nsw}
#{:sa :v}
#{:wa :nt}
#{:nt :q}
#{:q :nsw}
#{:nsw :v}
#{:t nil}])
(defn neighbors-of [kw]
(remove #(= % kw) (apply concat (filter kw arcs))))
(neighbors-of :sa)
; => (:wa :nt :q :nsw :v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment