Advertisement
bojandam1

Cas 22.10

Oct 24th, 2024
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.83 KB | None | 0 0
  1. is_leading([],_).
  2. is_leading([X|Ost],[X|Ost1]):-is_leading(Ost,Ost1).
  3.  
  4. podlista(L,L):-!.
  5. podlista([],_):-!.
  6. podlista([X|Ost],[X|Ost1]):-is_leading(Ost,Ost1),!.
  7. podlista([X|Ost],[_|Ost1]):-podlista([X|Ost],Ost1).
  8.  
  9.  
  10. e_list([]).
  11. e_list([_|_]).
  12.  
  13. trgni_nivo([],[]):-!.
  14. trgni_nivo([[X|Ost1]|Ost],[X|OstR]):-trgni_nivo([Ost1|Ost],OstR),!.
  15. trgni_nivo([[]|Ost],R):-trgni_nivo(Ost,R),!.
  16. trgni_nivo([X|Ost],R):-not(e_list(X)),trgni_nivo(Ost,R).
  17.  
  18. trgni_nadnivo([],[]):-!.
  19. trgni_nadnivo([X|Ost],[X|OstR]):-not(e_list(X)),trgni_nadnivo(Ost,OstR),!.
  20. trgni_nadnivo([X|Ost],R):-e_list(X),trgni_nadnivo(Ost,R).
  21.  
  22.  
  23. clenovi_nivo(1,L,R):-!,trgni_nadnivo(L,R).
  24. clenovi_nivo(N,L,R):-N1 is N-1,trgni_nivo(L,L1),clenovi_nivo(N1,L1,R).
  25.  
  26.  
  27. soberi_nivoa([],[]):-!.
  28. soberi_nivoa(L,[X|Ost]):-trgni_nadnivo(L,X),trgni_nivo(L,L1),soberi_nivoa(L1,Ost).
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement