Advertisement
exnon

insertHeapNeu

Dec 9th, 2020
3,645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.74 KB | None | 0 0
  1. insertHeap(Heap={Zh, L, R}, E, Steps = [l|_]) when E > Zh ->
  2.     {E, Lneu={Zh, {},{} }, {}};
  3. insertHeap(Heap={Zh, L, R}, E, Steps = [r|_]) when E > Zh ->
  4.     {E, L, {Rneu=Zh,{},{}}};
  5.    
  6. insertHeap(Heap={Zh, L, R}, E, Steps = [l|_]) when E =< Zh ->
  7.     {Zh, Lneu={E, {},{} }, {}};
  8. insertHeap(Heap={Zh, L, R}, E, Steps = [r|_]) when E =< Zh ->
  9.     {Zh, L, {Rneu=E,{},{}}};
  10.    
  11. insertHeap(Heap={Zh, L, R}, E, Steps = [l|T]) when E > Zh ->
  12.     {E, insertHeap(L,Zh, T), R};
  13. insertHeap(Heap={Zh, L, R}, E, Steps = [r|T]) when E > Zh ->
  14.     {E, L, insertHeap(R,Zh, T)};   
  15.  
  16. insertHeap(Heap={Zh, L, R}, E, Steps = [l|T]) when E =< Zh ->
  17.     {Zh, insertHeap(L,E, T), R};
  18. insertHeap(Heap={Zh, L, R}, E, Steps = [r|T]) when E =< Zh ->
  19.     {Zh, L, insertHeap(R,E, T)};   
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement