| … | … | @@ -670,6 +670,45 @@ |
| 670 | 670 | (cog-set-atomspace! current-as) |
| 671 | 671 | rules)) |
| 672 | 672 | |
| 673 | (define-public (cog-map-chase-link link-type endpoint-type proc anchor) |
| 674 | " |
| 675 | cog-map-chase-link -- Invoke proc on atom connected through type. |
| 676 | |
| 677 | Similar to cog-chase-link, but invokes 'proc' on the wanted atom. |
| 678 | Starting at the atom 'anchor', chase its incoming links of |
| 679 | 'link-type', and call procedure 'proc' on all of the atoms of |
| 680 | type 'endpoint-type' in those links. For example, if 'anchor' is the |
| 681 | node 'GivenNode \"a\"', and the atomspace contains |
| 682 | |
| 683 | SomeLink |
| 684 | GivenNode \"a\" |
| 685 | WantedNode \"p\" |
| 686 | |
| 687 | SomeLink |
| 688 | GivenNode \"a\" |
| 689 | WantedNode \"q\" |
| 690 | |
| 691 | then 'proc' will be called twice, with each of the WantedNodes's |
| 692 | as the argument. These wanted nodes were found by following the |
| 693 | link type 'SomeLink, starting at the anchor GivenNode \"a\". |
| 694 | |
| 695 | It is presumed that 'anchor' points to some atom (typically a node), |
| 696 | and that it has many links in its incoming set. So, loop over all of |
| 697 | the links of 'link-type' in this set. They presumably link to all |
| 698 | sorts of things. Find all of the things that are of 'endpoint-type'. |
| 699 | Apply proc to each of these. |
| 700 | " |
| 701 | (define (get-endpoint w) |
| 702 | (map proc (cog-outgoing-by-type w endpoint-type)) |
| 703 | ) |
| 704 | |
| 705 | ; We assume that anchor is a single atom, or empty list... |
| 706 | (if (null? anchor) |
| 707 | '() |
| 708 | (map get-endpoint (cog-incoming-by-type anchor link-type)) |
| 709 | ) |
| 710 | ) |
| 711 | |
| 673 | 712 | (define-public (ure-weighted-rules rbs) |
| 674 | 713 | " |
| 675 | 714 | List all weighted rules of rbs, as follow |