summaryrefslogtreecommitdiff
path: root/src/misc.prolog
blob: 6d8ad68a959440da3d44d54d0c6748234b449be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

:- module(misc, [filter/3, head/2, tail/2]).




filter(List, Predicate, Result) :-
    Test =.. [Predicate,X],
    findall(X, Test, No),
    subtract(List, No, Result).


head(X,[Y]) :- X = Y.
head(X,[Y|_]) :- X = Y.


tail(X,[]) :- X = [].
tail(X,[_]) :- X = [].
tail(X,[_|Y]) :- X = Y.