Advertisement
sb8623

list2.pl

Apr 18th, 2023
1,559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.67 KB | Source Code | 0 0
  1. %check if a list is doubletone or not
  2. doubletone([_, _]).
  3.  
  4. not_doubletone(L):-
  5.     not(doubletone(L)).
  6.  
  7. %whether two lists are same length or not
  8. length([], 0).
  9. length([X|Y], N):-
  10.     length(Y, N1),
  11.     N1 is N-1.
  12.  
  13. same_length(X, Y):-
  14.     length(X, L1), length(Y, L2), L1 =:= L2.
  15.  
  16. same_length2([X], [Y]).
  17. same_length2([X|L1], [Y|L2]):-
  18.     same_length2(L1, L2).
  19.  
  20. is_natural(0).
  21. is_natural(s(X)):-
  22.     is_natural(X).
  23.  
  24. even(0).
  25. odd(1).
  26. even(s(s(X))):-
  27.     even(X).
  28.  
  29. odd(s(s(X))):-
  30.     odd(X).
  31.  
  32. mutliple_three(0).
  33. multiple_three(s(s(s(X)))):-
  34.     mutiple_three(X).
  35.  
  36. is_less_than(0, Y):- is_natural(Y).
  37. is_less_than(s(X), s(Y)):- is_less_than(X, Y).
  38.  
  39.  
Tags: pl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement