chore: Demo & examples
This commit is contained in:
parent
61178cbeac
commit
b294467587
9 changed files with 228 additions and 23 deletions
14
examples/meta/my_list.pl
Normal file
14
examples/meta/my_list.pl
Normal file
|
@ -0,0 +1,14 @@
|
|||
% my_member(Element, List) - checks if Element is in List
|
||||
my_member(Element, Element) :- atomic(Element).
|
||||
my_member(Element, Compound) :-
|
||||
compound(Compound),
|
||||
Compound =.. [Head, Tail],
|
||||
(Element = Head ; my_member(Element, Tail)).
|
||||
|
||||
% my_length(List, Length) - finds the my_length of a list
|
||||
my_length(Atom, 1) :- atomic(Atom).
|
||||
my_length(Compound, N) :-
|
||||
compound(Compound),
|
||||
Compound =.. [_, Tail],
|
||||
my_length(Tail, M),
|
||||
N is M + 1.
|
Reference in a new issue