diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-20 09:22:38 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-20 09:22:38 -0800 |
commit | 94e27fde1397ec45bc77406a4c6914abef61d681 (patch) | |
tree | b09967f1d958e9ccc77d4b0f051f8abca5f3ac5a | |
parent | db94af675ccfb34885000e3d97947557cebb66f3 (diff) | |
download | standingwithresilience-94e27fde1397ec45bc77406a4c6914abef61d681.tar.gz standingwithresilience-94e27fde1397ec45bc77406a4c6914abef61d681.zip |
some habits
-rw-r--r-- | starts/meaning-vm/habit-starts/learning-parts.cpp | 74 |
1 files changed, 66 insertions, 8 deletions
diff --git a/starts/meaning-vm/habit-starts/learning-parts.cpp b/starts/meaning-vm/habit-starts/learning-parts.cpp index 7f4c324..8eb84ea 100644 --- a/starts/meaning-vm/habit-starts/learning-parts.cpp +++ b/starts/meaning-vm/habit-starts/learning-parts.cpp @@ -50,12 +50,34 @@ static int __init = ([]()->int{ s.link(t, dst); }); - decls(linked) - ahabit(linked, ((source, s), (type, t), (target, dst)), + decls(linked, anything); + ahabit(linked, ((source, s), (type, t), (target, dst, anything)), { - // i'd like to make target optional - // i wonder how to upgrade macro for - // could also use preprocessing stage + if (dst == anything) { + result = s.linked(t); + } else { + result = s.linked(t, dst); + } + }); + + decls(unlink); + ahabit(unlink, ((source, s), (type, t), (target, dst, anything)), + { + if (dst == anything) { + result = s.unlink(t); + } else { + result = s.unlink(t, dst); + } + }); + + ahabit(get, ((source, s), (type, t)), + { + result = s.get(t); + }); + + ahabit(set, ((source, s), (type, t), (target, dst)), + { + }); // we want the habits expressive enough to code efficiently in. @@ -82,7 +104,7 @@ static int __init = ([]()->int{ }); // separate habits and behaviors. - // behaviors are modifiableb data run hy immutable habits. + // behaviors are modifiable data run hy immutable habits. // they use translation maps to move concepts between // subhabits. // translation map is just list of equivalent pairs @@ -105,17 +127,53 @@ static int __init = ([]()->int{ decls(list, nothing, next, previous); decls(make, add, to, until, each, item, in, remove, from, somewhere); - // list functiona are habits because orderes-behavior + // list functiona are habits because ordered-behavior // would use a list + // lists are being handled by providing a habit that + // can be engaged for every item. it responds to the item. + // i was thinking it could be better to respond to the next-link. + // these are roughly the same thing. + // when doing an ordered behavior we want to act in response to + // going to the next step, so we can decide to. + // 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 + // can be handled innumerable ways. + // LIST STRUCTURE PROMISE ahabit(make-list, ((list, l)), { result = a(list, l); link(result, first-item, nothing); link(result, last-item, nothing); }); + ahabit(make-list-item, ((item, i), (previous, prev, nothing), (next, n, nothing)), + { + result = a(list-item); + link(result, item, i); + link(result, previous, prev); + link(result, next, n); + }); + ahabit(list-first-item, ((list, l)), + { + result = l.get(first-item); + }); + ahabit(list-last-item, ((list, l)), + { + result = l.get(last-item); + }); + ahabit(listitem-next, ((item, i)), + { + result = i.get(next); + }); + ahabit(listitem-previous, ((item, i)), + { + result = i.get(previous); + }); + ahabit(add-to-list, ((item, i), (list, l)), { - ref prev = l.get(last-item); + ref prev = (list-last-item)(l); ref li = a(list-item); li.link(item, i); li.link(next, nothing); |