umm I got another one for ya man...
last_element(+List, -LastElement)
Succeeds with LastElement equal to the last element of List. If List is not a list or is empty, it fails.
last_element([X], X).
last_element([_|T], X) :-
last_element(T, X).
any suggestions? :/
sum(+List, -Sum)
Succeeds with Sum equal to the sum of all the entries on list. The empty list has sum 0, and if List is not a list of numeric values, sum fails or results in an error.
It is nearly close but I got this so far...
sum([], 0) :- !.
sum(N, N) :- number(N), !.
sum([H|T], N) :-...
hey guys, I am currently a noob to swi-prolog. I've been trying to figure out bunch of things and I was working on some questions in the beginner book I bought... I got stuck on some of them. I hope to get some help in here since this is one of the best ones I found.
remove_duplicates(+List...
hey guys, I am currently a noob to swi-prolog. I've been trying to figure out bunch of things and I was working on some questions in the beginner book I bought... I got stuck on some of them. I hope to get some help in here since this is one of the best ones I found.
remove_duplicates(+List...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.