diff options
author | user <user@localhost.localdomain> | 2019-12-21 06:45:50 -0800 |
---|---|---|
committer | user <user@localhost.localdomain> | 2019-12-21 06:45:50 -0800 |
commit | 8ab69b673852971103e89eafa15a1dc6385b56ce (patch) | |
tree | f61be324b4ad223cd8e413a1e40f885a28de0460 | |
parent | 23641371d1a8f5700f629783f6b06b6d27fa70a2 (diff) | |
download | standingwithresilience-8ab69b673852971103e89eafa15a1dc6385b56ce.tar.gz standingwithresilience-8ab69b673852971103e89eafa15a1dc6385b56ce.zip |
wip
-rw-r--r-- | starts/meaning-vm/habit-starts/learning-parts.cpp | 54 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/funcs.cpp | 2 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/funcs.hpp | 4 |
3 files changed, 36 insertions, 24 deletions
diff --git a/starts/meaning-vm/habit-starts/learning-parts.cpp b/starts/meaning-vm/habit-starts/learning-parts.cpp index 41e8356..c53b260 100644 --- a/starts/meaning-vm/habit-starts/learning-parts.cpp +++ b/starts/meaning-vm/habit-starts/learning-parts.cpp @@ -138,43 +138,57 @@ static int __init = ([]()->int{ // this maps to the step list item. if result is to stop, list // stops iteration. // may want a more meaningful exploration of list. not sure - // list is mostly the [first-item, last-item, next, prev] structure + // list is mostly the [first-entry, last-entry, next, prev] structure // can be handled innumerable ways. // LIST STRUCTURE PROMISE - ahabit(make-list, ((list, l)), + // should be a promise yandled by habits rather than + // a bunch of specific habits, but is ok for now + // is likely good for mind to discover + // promises and structures on its own + ahabit(know-is-list, ((list, l)), { - result = a(list, l); - link(result, first-item, nothing); - link(result, last-item, nothing); + result = l; + (know-is)(l, list); + link(l, first-item, nothing); + link(l, last-item, nothing); }); - ahabit(make-list-item, ((item, i), (previous, prev, nothing), (next, n, nothing)), + ahabit(know-is-list-entry, ((list-entry, l), (item, i), (previous, prev, nothing), (next, n, nothing)), { - result = a(list-item); - link(result, item, i); - link(result, previous, prev); - link(result, next, n); + result = l; + (know-is)(l, list-entry); + link(l, item, i); + link(l, previous, prev); + link(l, next, n); }); ahabit(list-first-item, ((list, l)), { - result = l.get(first-item); + result = get(l, first-item); }); ahabit(list-last-item, ((list, l)), { - result = l.get(last-item); + result = get(l, last-item); }); - ahabit(listitem-next, ((item, i)), + ahabit(list-entry-next, ((list-entry, i)), { - result = i.get(next); + result = get(i, next); }); - ahabit(listitem-previous, ((item, i)), + ahabit(list-entry-previous, ((list-entry, i)), { - result = i.get(previous); + result = get(i, previous); + }); + ahabit(list-entry-item, ((list-entry, e)), + { + result = get(e, item); }); ahabit(add-to-list, ((item, i), (list, l)), { ref prev = (list-last-item)(l); - ref li = a(list-item); + ref li = (know-is-list-entry)( + (make-concept)(), + item, + nothing, + prev); li.link(item, i); li.link(next, nothing); li.link(previous, prev); @@ -188,9 +202,7 @@ static int __init = ([]()->int{ prev.set(next, li); } }); - // TODO: this is a useful function with way too much verbosity - // please make it simple, later. - ahabit(until-each-list-item-context-in-list, ((action, a), (context, c), (list, l)), + ahabit(each-list-entry, ((action, a), (context, c), (list, l)), { ref cur = l.get(first-item); while (cur != nothing && result == nothing) { @@ -198,7 +210,7 @@ static int __init = ([]()->int{ cur = cur.get(next); } }); - ahabit(remove-from-somewhere-in-list, ((item, i), (list, l)), + ahabit(remove-from-list, ((item, i), (list, l)), { result = (until-each-list-item-context-in-list)( ahabit(self-iter, ((list-item, i2), (remove-item, i)), diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp index e4fc090..36f93ca 100644 --- a/starts/meaning-vm/level-2/funcs.cpp +++ b/starts/meaning-vm/level-2/funcs.cpp @@ -17,7 +17,7 @@ ref & context() return ctx; } -ref makehabit(ref name, std::initializer_list<ref> argnames, std::function<void(ref)> code) +ref makehabit(ref name, std::initializer_list<ref> argnames, std::initializer_list<ref> defaults, std::function<void(ref)> code) { ref habit = level1::a(concepts::habit, name); ref posarg = habit; diff --git a/starts/meaning-vm/level-2/funcs.hpp b/starts/meaning-vm/level-2/funcs.hpp index 65290fb..d1d1d7d 100644 --- a/starts/meaning-vm/level-2/funcs.hpp +++ b/starts/meaning-vm/level-2/funcs.hpp @@ -11,8 +11,8 @@ namespace level2 { ref & context(); // TODO: pass default argument values to makehabit? ref makehabit(ref name, std::initializer_list<ref> argnames, std::function<void(ref)> code); -ref dohabit(ref habit, std::initializer_list<ref> args); -ref dohabit(ref habit, std::initializer_list<std::initializer_list<ref>> args = {}); +ref dohabit(ref habit, std::initializer_list<ref> args = {}); +ref dohabit(ref habit, std::initializer_list<std::initializer_list<ref>> args); } } |