CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 06:14:57 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=7f9e1354c196cf0b63aa90c60e9046af41a98e12091562dc2187ca38f7d08a17a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%228_J9SP5d2ZiItru5CIene4r73kw_WX0W%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cc385e2d678087-BLR
list.pl - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Given a list L we want to find wether an element X is a member of that list or not.
- member(X, [X | _ ]).
- member(X, [Y | Rest]):-
- member(X, Rest).
- % Concatenate list L1 and L2 to form list L3
- concat([], L, L).
- concat([X|L1], L2, [X|L3]):-
- concat(L1, L2, L3).
- member1(X, L):-
- concat(L1, [X|L2], L).
- % adding an item X to the beginning of a list L
- add(X, L, [X|L]).
- %delete the first occurence of the element X of a list L
- del(X, [X|L], L).
- del(X, [Y|Rest], [Y|L1]):-
- del(X, Rest, L1).
- del_all(X, [], []).
- del_all(X, [X|L], L1):-
- del_all(X, L, L1).
- del_all(X, [Y|L], L1):-
- del_all(X, L, L2),
- concat([Y], L2, L1).
- %find out the last member of a list.
- lastmember([X], X).
- lastmember([_|L], X):-
- lastmember(L, X).
- %find the reverse of a list
- reverselist([], []).
- reverselist([X], [X]).
- reverselist([X | L], L1):-
- reverselist(L, L2),
- concat(L2, [X], L1).
- %check palindrome of a list
- palindrome(L):-
- reverselist(L, L).
- %insert in X in all possible positions
- insert_all_pos(X, [], [X]).
- insert_all_pos(X, [Y|T], [X,Y|T1]):-
- insert_all_pos(X, T, T1).
- %check palindrome using concatenate
- palindrome1([]).
- palindrome1([_]).
- palindrome1([H|T]):-
- concat(L, [H], T),
- palindrome1(L).
- %check whether a list is of odd length
- even([]).
- odd([_]).
- even([H|T]):-
- odd(T).
- odd([H|T]):-
- even(T).
- %find out the length of a list
- length([], 0).
- length([X|Y], N):-
- length(Y, N1),
- N1 is N-1.
- %find all prefixes and suffixes of a list
- prefix([], L).
- prefix([X|Y], [X|Y1]):-
- prefix(Y, Y1).
- suffix(L, L).
- suffix(L1, [_|L2]):-
- suffix(L1, L2).
- %find all permutations of a list
Tags:
pl
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 1 sec ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 10 sec ago | 0.24 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 20 sec ago | 0.24 KB
-
⭐ Free Crypto Method ✅ NEVER SEEN BEFORE ⭐⭐⭐
JavaScript | 31 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ✅ NEVER SEEN...
JavaScript | 42 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 51 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 1 min ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 1 min ago | 0.24 KB
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