Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Name all free variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakan Raberg committed Oct 1, 2012
1 parent 8c6b715 commit 26b6edb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/mimir/mk.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns mimir.mk
(:use [clojure.tools.logging :only (debug info warn error spy)]
[mimir.match :only (prepare-matcher *match-var?* match-any bind-vars MatchAny)]
[mimir.match :only (filter-walk prepare-matcher *match-var?* match-any bind-vars MatchAny)]
[clojure.walk :only (postwalk-replace)])
(:import [java.io Writer]
[clojure.lang Symbol Seqable])
Expand Down Expand Up @@ -35,8 +35,8 @@
MatchVar
(match-var [x this acc] (match-any x this acc))

Seqable ; hack for consᵒ
(seq [this] (seq ['& this]))
;; Seqable ; hack for consᵒ
;; (seq [this] (seq ['& this]))

Object
(hashCode [this] (.hashCode name))
Expand Down Expand Up @@ -98,9 +98,9 @@

(defn ^:private reify-goal [xs s]
(let [xs (map #(reify % s) xs)
vs (filter var? xs)
vs (distinct (filter-walk var? xs))
vs (zipmap vs (map-indexed (fn [idx _] (reify-name idx)) vs))]
(replace vs xs)))
(postwalk-replace vs xs)))

(defmacro run* [[& x] & g]
`(run-internal (exist [~@x] ~@g (partial reify-goal ~(vec x))) [{}]))
Expand All @@ -112,7 +112,8 @@
(def fail ( false true))

(defn consᵒ [a d l]
( (cons a d) l))
(let [d (if (var? d) ['& d] d)]
( l (cons a d))))

(defn firstᵒ [l a]
(fresh [d]
Expand Down

0 comments on commit 26b6edb

Please sign in to comment.