SHARE
TWEET

Untitled

f0rsakenbg Apr 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List1 = [1, 2, 3, 4, 5] &
  2. List2 = [5, 6, 7, 8] &
  3. ExpRes = [1, 2, 3, 4] &
  4. compare (List1, List2, [], Result) &
  5. append (Ls, NewElem, _NewLs);
  6.  
  7. append ([], NewElem, [NewElem]) :-
  8.     !
  9. ;
  10.  
  11. append ([Head | Tail], NewElem, [Head | TempRes]) :-
  12.     append (Tail, NewElem, TempRes)
  13. ;
  14.  
  15. compare ([], _List2, Acc, Acc) :-
  16.     !
  17. ;
  18.  
  19. compare ([Head | Tail], List2, Acc, Res) :-
  20.     not Head in List2 &
  21.     ! &
  22.     append (Acc, Head , NewAcc) &
  23.     compare (Tail, List2, NewAcc, Res)
  24. ;
  25.  
  26. compare ([_Head | Tail], List2, Acc, Res) :-
  27.     compare (Tail, List2, Acc, Res)
  28. ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top