summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level2.cpp
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-26 17:32:50 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-26 17:32:50 -0800
commit9307772f43a2694aac64b0e86c8873b93d77f0ae (patch)
tree8251f7c0722fc2de3068ed2238385b95ca7dec0e /starts/meaning-vm/level2.cpp
parent94ed7bbaa739995a9815b5f1c916d9e24575368c (diff)
downloadstandingwithresilience-9307772f43a2694aac64b0e86c8873b93d77f0ae.tar.gz
standingwithresilience-9307772f43a2694aac64b0e86c8873b93d77f0ae.zip
making a behavior
Diffstat (limited to 'starts/meaning-vm/level2.cpp')
-rw-r--r--starts/meaning-vm/level2.cpp62
1 files changed, 61 insertions, 1 deletions
diff --git a/starts/meaning-vm/level2.cpp b/starts/meaning-vm/level2.cpp
index ebdf121..bfda42f 100644
--- a/starts/meaning-vm/level2.cpp
+++ b/starts/meaning-vm/level2.cpp
@@ -7,6 +7,56 @@
using namespace intellect::level2;
using namespace intellect::level2::concepts;
+// makes a list in one call =)
+void filllist(ref list, std::initializer_list<ref> items)
+{
+ for (auto & i : items) {
+ (make-next-list-entry)(list, i);
+ }
+}
+ref makelist(std::initializer_list<ref> items)
+{
+ ref list = (make-concept)();
+ (know-is-list)(list);
+ filllist(list, items);
+ return list;
+}
+
+// join refs with commas
+#define symbolstorefs(...) _macro_for_each(symboltoref, commasymboltoref, __VA_ARGS__)
+#define symboltoref(sym) ref(#sym)
+#define commasymboltoref(sym) , ref(#sym)
+
+// karl is implementing much of the macro work for level3
+// to meet a request to have the implementation of this test function be less verbose
+// karl's choices when developing have been altered to change the result.
+// has own behavior for optimizing choices for result
+// but behavior was used for money, maybe political change
+// now parts of it are malfunctioning badly
+// karl likes to code assuming there is no need to finish
+// order here matters not. continue.
+
+// helper function for making a codeline
+ref makestep(ref habit, ref result, std::initializer_list<ref> ins)
+{
+ // build needed-information-map, made-information-map, action
+ // then pass to make-context-action.
+ ref nim = (make-concept)(), mim = (make-concept)();
+ (know-is-list)(nim); (know-is-list)(mim);
+ if (result != nothing) {
+ (make-next-list-entry)(mim, (make-map-item)("result", result));
+ }
+ ref infn = habit.get(information-needed);
+ for (ref in : ins) {
+ infn = infn.get(next-information);
+ (make-next-list-entry)(nim, (make-map-item)(in, infn[information]));
+ }
+ return (make-context-action)(nim, mim, habit);
+}
+#define step(action, ...) makestep(action, ref("nothing"), { symbolstorefs(__VA_ARGS__) })
+#define fromstep(result, action, ...) makestep(action, ref(#result), { symbolstorefs(__VA_ARGS__) })
+
+
int main()
{
decls(dump, name, of, is, nothing);
@@ -31,9 +81,19 @@ int main()
}
});
// I guess I'd better code dump as a behavior.
+ decls(dump, type, target);
+ ref dump = ref("dump");
+ (know-is-list)(dump);
+ filllist(dump,
+ {
+ // make steps for all parts of dump
+ step(),
+ fromstep(),
+ });
+ link(dump, habit, action-list);
+ // for dump, we make a list of contextual actions
ahabit(dump, ((concept, c)),
{
- decls(type, target);
static std::set<ref> dumped;
if (dumped.count(c) == 0) {
std::cout << (name-of)(c).val<std::string>() << ":" << std::endl;