frumos(astazi). frumos(ieri). % frumos(maine) :- false. % fail frumos(Zi) :- zi(Zi), \+ ploua(Zi). % nu se poate demonstra ca ploua(Zi) % :- = "dacă" (seamana cu <= ) % , = si % ; = sau ploua(maine). ploua(intai_mai). zi(maine). zi(poimaine). zi(intai_mai). zi(doi_mai). zi(treizeci_aprilie). % Alice came across a lion and a unicorn in a forest of forgetfulness. % Those two are strange beings. % The lion lies every Monday, Tuesday and Wednesday % and the other days he speaks the truth. % The unicorn lies on Thursdays, Fridays and Saturdays, % however the other days of the week he speaks the truth. % Lion: Yesterday I was lying. % Unicorn: So was I. % Which day did they say that? days([mon, tue, wed, thu, fri, sat, sun]). % is_next/3 % is_next(+Day, +NextDay, +DaysList) is_next(D1, D2, [D1, D2 | _]). is_next(D1, D2, [_|RestDays]) :- is_next(D1, D2, RestDays). yesterday(Today, Yesterday) :- days(Days), member(Today, Days), member(Yesterday, Days), is_next(Yesterday, Today, Days). yesterday(mon, sun). % myMember(?E, +L) myMember(E, [E|_]). %myMember(E, L) :- [H|T]=L, myMember(E, T). myMember(E, [_|T]) :- myMember(E, T). % first_two(+L, -E1, -E2) %first_two(L, E1, E2) :- [E1, E2 | _]=L. first_two([E1, E2 | _], E1, E2). sumList([], 0). sumList([H|T], Sum) :- sumList(T, SumTail), Sum is H + SumTail.