Advertisement
steffffffan

P2_6

Nov 20th, 2022
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.40 KB | None | 0 0
  1. %6.
  2. %a) Intr-o lista L sa se inlocuiasca toate aparitiile unui element E cu
  3. %elementele unei alte liste, L1. De ex: inloc([1,2,1,3,1,4],1,[10,11],X)
  4. %va produce X=[10,11,2,10,11,3,10,11,4].
  5.  
  6. lstconcat([],A,A):-!.
  7. lstconcat([H|T],A,[H|R]):-lstconcat(T,A,R).
  8.  
  9.  
  10. inloc([],_,_,[]):-!.
  11. inloc([E|T],E,L,R):-!,
  12.     inloc(T,E,L,R1),
  13.     lstconcat(L,R1,R).
  14.  
  15. inloc([H|T],E,L,[H|R]):-
  16.     inloc(T,E,L,R).
  17.  
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement