aboutsummaryrefslogtreecommitdiff
path: root/miniMAL/core.json
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-02-16 01:15:35 -0600
committerJoel Martin <github@martintribe.org>2015-02-24 09:17:45 -0600
commitad28cf3cb19d91399c52149d798f6c6efb780a51 (patch)
treec92e35586cc92dc146868482701c39393895a649 /miniMAL/core.json
parent320455465294f170f54cda772142f4de4cb6f602 (diff)
downloadmal-ad28cf3cb19d91399c52149d798f6c6efb780a51.tar.gz
mal-ad28cf3cb19d91399c52149d798f6c6efb780a51.zip
miniMAL: add metadata support.
Diffstat (limited to 'miniMAL/core.json')
-rw-r--r--miniMAL/core.json21
1 files changed, 20 insertions, 1 deletions
diff --git a/miniMAL/core.json b/miniMAL/core.json
index cec9156..9799b16 100644
--- a/miniMAL/core.json
+++ b/miniMAL/core.json
@@ -54,6 +54,22 @@
["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"]],
["map", "fn", "seq"]]]],
+["def", "with_meta", ["fn", ["obj", "m"],
+ ["let", ["new-obj", ["clone", "obj"]],
+ ["do",
+ ["set", "new-obj", ["`", "__meta__"], "m"],
+ "new-obj"]]]],
+
+["def", "meta", ["fn", ["obj"],
+ ["if", ["or", ["sequential?", "obj"],
+ ["map?", "obj"],
+ ["malfunc?", "obj"]],
+ ["if", ["contains?", "obj", ["`", "__meta__"]],
+ ["get", "obj", ["`", "__meta__"]],
+ null],
+ null]]],
+
+
["def", "core-ns",
["hash-map",
["`", "="], "equal?",
@@ -114,6 +130,9 @@
["`", "empty?"], "empty?",
["`", "count"], "_count",
["`", "apply"], "_apply",
- ["`", "map"], "_map"]],
+ ["`", "map"], "_map",
+
+ ["`", "with-meta"], "with_meta",
+ ["`", "meta"], "meta"]],
null]