chore: Demo & examples

This commit is contained in:
Tibo De Peuter 2025-05-18 23:27:35 +02:00
parent 61178cbeac
commit b294467587
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
9 changed files with 228 additions and 23 deletions

14
examples/meta/my_list.pl Normal file
View 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.