Reindent things

This commit is contained in:
Scott Richmond 2022-03-19 19:09:21 -04:00
parent 90f6fa8b19
commit 2a099298f0

View File

@ -32,19 +32,14 @@
(= 0 (:length pattern) (dec (count value))) {:success true :ctx {}}
:else (let [members (:members pattern)]
(loop [i (dec (:length pattern))
(loop [i (:length pattern)
ctx {}]
(if (= 0 i)
{:success true :ctx ctx}
(let [match? (match (nth members i) (nth value (inc i)) ctx-atom)]
(let [match? (match (nth members (dec i)) (nth value i) ctx-atom)]
(if (:success match?)
(recur (dec i) (merge ctx (:ctx match?)))
{:success false :reason (str "Could not match " pattern " with " value)}
))
)
))
))
{:success false :reason (str "Could not match " pattern " with " value)})))))))
(defn- match [pattern value ctx-atom]
(let [ctx @ctx-atom]
@ -74,6 +69,8 @@
)))
(defn- update-ctx [ctx new-ctx]
(println "Adding to context:")
(pp/pprint new-ctx)
(merge ctx new-ctx))
;; TODO: get "if let" pattern working
@ -157,7 +154,8 @@
(do
(def source "
let (:foo, 1, :bar) = (:foo, 1, :bar)
let (foo, (_, baz)) = (1, (2, 3))
baz
")
(println "")