diff --git a/README.md b/README.md index 9acefa54da819cb51d144aa3430a0b31616891ec..409cac9dba55f505bfe5a8d7946f07ea9a9c19fc 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,23 @@ -# Fiche aide IA02 Prolog -## Member +### Member ```prolog member(X, [X|_]). member(X, [_|Tail]) :-, member(X, Tail). ``` -## Append / Concat +### Append / Concat ```prolog append([],X,X). append([X|Y],Z,[X|W]) :- append(Y,Z,W). ``` -## Reverse +### Reverse ```prolog reverse([],[]). reverse([X|Xs],YsX) :- reverse(Xs,Ys), append(Ys,[X],YsX). ``` -## Length +### Length ```prolog len([], 0). len([_ | Tail], Length) :- @@ -26,13 +25,13 @@ len([_ | Tail], Length) :- Length is Length1 + 1,!. ``` -## Nième élément +### Nième élément ```prolog element_n(1,[X|Q],X):-!. element_n(N,[T|Q],X):-M is N-1, element_n(M,Q,X). ``` -## Tri à bulles +### Tri à bulles ```prolog bubble_sort(List,Sorted):-b_sort(List,[],Sorted). b_sort([],Acc,Acc). @@ -42,3 +41,21 @@ bubble(X,[],[],X). bubble(X,[Y|T],[Y|NT],Max):-X>Y,bubble(X,T,NT,Max). bubble(X,[Y|T],[X|NT],Max):-X=