home *** CD-ROM | disk | FTP | other *** search
- (literalize node
- name
- level
- lc
- rc
- val)
-
- (literalize current
- name)
-
- (literalize right_child
- name)
-
- (literalize left_child
- name)
-
- (literalize pattern
- val)
-
- (literalize strategy
- type)
-
- (p init
- (start)
- -->
- (write (crlf) Type in an exact match pattern to search for (crlf))
- (bind <val> (accept))
- (write (crlf) Type in breadth or depth to indicate search strategy
- (crlf))
- (bind <strat> (accept))
- (make pattern ^val <val>)
- (remove 1)
- (make get-root)
- (make make-strategy <strat>))
-
- (p breath-first-search
- (make-strategy breadth)
- {<strat> (strategy)}
- -->
- (remove 1)
- (modify <strat> ^type breadth)
- (rule-priority do-level high))
-
- (p depth-first-search
- (make-strategy depth)
- {<strat> (strategy)}
- -->
- (remove 1)
- (modify <strat> ^type depth)
- (rule-priority do-level low))
-
- (p get-root
- (get-root)
- (node ^level 1 ^name <name>)
- -->
- (remove 1)
- (make current ^name <name>))
-
- (p dump-nil
- (<< left_child right_child >> ^name nil)
- -->
- (remove 1))
-
- (p check-current-found
- (current ^name <name>)
- (pattern ^val <value>)
- (node ^name <name> ^val <value>)
- -->
- (write (crlf) found current value: <value> at <name>)
- (halt))
-
- (p check-current-not-found
- (current ^name <name>)
- (pattern ^val <value>)
- (node ^name <name> ^val <> <value> ^lc <lc> ^rc <rc>)
- -->
- (remove 1)
- (make right_child ^name <rc>)
- (make left_child ^name <lc>))
-
- (p do-level
- (current ^name <name>)
- (pattern ^val <value>)
- (node ^name <name> ^level <lev> ^val <> <value>
- ^lc <lc> ^rc <rc>)
- {<samlev>
- ( {<child> << left_child right_child >>}
- ^name <aname>)}
- (node ^name <aname> ^level <lev>)
- (strategy ^type <strat>)
- -->
- (write (crlf)
- <strat> searching <child> <aname> at level: <lev>)
- (remove 1 <samlev>)
- (make right_child ^name <rc>)
- (make left_child ^name <lc>)
- (make current ^name <aname>))
-
- (p depth-next
- {<cur> (left_child ^name {<name> <> nil})}
- (node ^name <name> ^level <lev>)
- (strategy ^type <strat>)
- -->
- (write (crlf)
- <strat> searching left child <name> at level: <lev>)
- (make current ^name <name>)
- (remove <cur>))
-
- (p breadth-next
- {<cur> (right_child ^name {<rname> <> nil})}
- (node ^name <rname> ^level <lev>)
- (strategy ^type <strat>)
- -->
- (write (crlf)
- <strat> searching right child <rname> at level: <lev>)
- (make current ^name <rname>)
- (remove <cur>))
-
- (priority low -2)
-
- (priority high 2)
-
- (priority normal 0)
-
- (load |examples\trees.dat|)