diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-23 12:43:17 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-23 12:43:17 -0800 |
commit | 8db6ac879adf30e9e1aa61a8b441dea2ff09f9fb (patch) | |
tree | ff7c7f4e58fc3348e86b32506c1a4a262d0335b9 /starts | |
parent | eaff501ca8f5106f95f2268f9cd2162a58826cf2 (diff) | |
parent | c8e3e06b79c54f67961fdeba1504ec1cca206719 (diff) | |
download | standingwithresilience-8db6ac879adf30e9e1aa61a8b441dea2ff09f9fb.tar.gz standingwithresilience-8db6ac879adf30e9e1aa61a8b441dea2ff09f9fb.zip |
Merge branch 'master' of xloem.github:xloem/intellect
Diffstat (limited to 'starts')
-rw-r--r-- | starts/meaning-vm/.gitignore | 1 | ||||
-rw-r--r-- | starts/meaning-vm/habit-starts/learning-parts.cpp | 37 | ||||
-rw-r--r-- | starts/meaning-vm/level-0/baseref.hpp | 12 |
3 files changed, 44 insertions, 6 deletions
diff --git a/starts/meaning-vm/.gitignore b/starts/meaning-vm/.gitignore index ff3f1d3..206b76d 100644 --- a/starts/meaning-vm/.gitignore +++ b/starts/meaning-vm/.gitignore @@ -2,5 +2,6 @@ *.ii *.o *.a +*.tmp level? habit-starts/rhythm diff --git a/starts/meaning-vm/habit-starts/learning-parts.cpp b/starts/meaning-vm/habit-starts/learning-parts.cpp index 7b3000e..56c7ffa 100644 --- a/starts/meaning-vm/habit-starts/learning-parts.cpp +++ b/starts/meaning-vm/habit-starts/learning-parts.cpp @@ -235,6 +235,43 @@ static int __init = ([]()->int{ })); }); + using links_it = level0::baseref::links_t::iterator; + ahabit(populate-link-entry, ((link-entry, le)), + { + result = le; + auto & it = result.vget<links_it>(); + if (it != result["source"].links().end()) { + result.set("type", it->first); + result.set("target", it->second); + } else { + result.unlink("type"); + result.unlink("target"); + } + }); + ahabit(first-link-entry, ((concept, c)), + { + result = level1::alloc(level, c.links().begin()); + result.set("source", c); + (populate-link-entry)(result); + }); + ahabit(last-link-entry, ((concept, c)), + { + result = level1::alloc(level, --c.links().end()); + result.set("source", c); + (populate-link-entry)(result); + }); + ahabit(next-link-entry, ((link-entry, le)), + { + result = le; + ++result.vget<links_it>(); + (populate-link-entry)(result); + }); + ahabit(previous-link-entry, ((link-entry, le)), + { + result = le; + --result.vget<links_it>(); + (populate-link-entry)(result); + }); /* ahabit(happened-habit, ((happened, ev)), diff --git a/starts/meaning-vm/level-0/baseref.hpp b/starts/meaning-vm/level-0/baseref.hpp index 69880c8..d20b22a 100644 --- a/starts/meaning-vm/level-0/baseref.hpp +++ b/starts/meaning-vm/level-0/baseref.hpp @@ -108,18 +108,18 @@ private: struct array { - mutated_it<ref,typename concept::array::iterator> begin() { return array.begin(); } - mutated_it<ref,typename concept::array::iterator> end() { return array.end(); } + using iterator = mutated_it<ref,typename concept::array::iterator>; + iterator begin() { return array.begin(); } + iterator end() { return array.end(); } typename concept::array array; }; struct links_t { - mutated_it<std::pair<ref,ref>,typename decltype(concept::links)::iterator> begin() - { return links.begin(); } - mutated_it<std::pair<ref,ref>,typename decltype(concept::links)::iterator> end() - { return links.end(); } + using iterator = mutated_it<std::pair<ref,ref>,typename decltype(concept::links)::iterator>; + iterator begin() { return links.begin(); } + iterator end() { return links.end(); } decltype(concept::links) & links; }; |