aboutsummaryrefslogtreecommitdiff
path: root/src/lang/util.clj
diff options
context:
space:
mode:
authorEduardo Julian2014-11-26 19:26:22 -0400
committerEduardo Julian2014-11-26 19:26:22 -0400
commita96bb768a5f02c2dc9c0de1e50dc14376d2e7f35 (patch)
tree2387d0bf4cf171475f0f564c9006e0546bac48e3 /src/lang/util.clj
parent5bf50ef978eb88e2e61c40f3bb0fea523115e770 (diff)
+ Can now define functions.
% However, they currently access Clojure's environment, instead of the interpreter's.
Diffstat (limited to 'src/lang/util.clj')
-rw-r--r--src/lang/util.clj19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lang/util.clj b/src/lang/util.clj
index 1290d91df..d9745e9ab 100644
--- a/src/lang/util.clj
+++ b/src/lang/util.clj
@@ -58,12 +58,15 @@
(fn [state]
(match (monad state)
[::ok [?state ?head]]
- ((exec [tail (repeat-m monad)]
- (return (cons ?head tail)))
- ?state)
+ (do ;; (prn 'repeat-m/?state ?state)
+ (match ((repeat-m monad) ?state)
+ [::ok [?state* ?tail]]
+ (do ;; (prn 'repeat-m/?state* ?state*)
+ (return* ?state* (cons ?head ?tail)))))
- [::failure _]
- (return* state '()))))
+ [::failure ?message]
+ (do ;; (println "Failed at last:" ?message)
+ (return* state '())))))
(defn try-all-m [monads]
(fn [state]
@@ -90,7 +93,7 @@
(fn [state]
;; (prn 'apply-m monad call-state)
(let [output (monad call-state)]
- ;; (prn 'output output)
+ ;; (prn 'apply-m/output output)
(match output
[::ok [?state ?datum]]
[::ok [state ?datum]]
@@ -105,3 +108,7 @@
(defn pass [m-value]
(fn [state]
m-value))
+
+(def get-state
+ (fn [state]
+ (return* state state)))