Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:trees_heap_2 [2019/06/27 15:50]
pl:prolog:pllib:trees_heap_2 [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Trees heap 2 ======
 +{{tag>​trees heap}}
 +===== Description =====
 +Adjusting a binary tree to satisfy the heap property.
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{trees_heap_2.pl}}
 +===== Listing =====
 +<code prolog>
 +/*
 + substitute(X,​Y,​TreeX,​TreeY) :- 
 + The binary tree TreeY is the result of replacing all 
 + occurrences of X in the binary tree TreeX by Y.
 +*/
 +
 + substitute(X,​Y,​void,​void).
 + substitute(X,​Y,​tree(Leaf,​Left,​Right),​tree(Leaf1,​Left1,​Right1)) :-
 + replace(X,​Y,​Leaf,​Leaf1),​
 + substitute(X,​Y,​Left,​Left1), ​
 + substitute(X,​Y,​Right,​Right1).
 +
 + replace(X,​Y,​X,​Y).
 + replace(X,​Y,​Z,​Z) :- X \== Z.
 +
 +% Program 3.26: Substituting for a term in a tree
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/trees_heap_2.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0