Last active
November 28, 2015 23:24
-
-
Save lotka/d39b0da96ede6ca3565c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
life(good). | |
life(bad). | |
life(okay). | |
setOfLifeOutcomes(X) :- | |
lengthAcc(X,0). | |
getAcc([],_,_). | |
getAcc([H|T],Acc,N) :- | |
Acc > N -> ! ; | |
(NewAcc is Acc+1, | |
getAcc(T,NewAcc,N), | |
life(H), | |
\+member(H,T)). | |
getHelper(List,Length) :- | |
getAcc(List,0,Length), | |
length(List,Length), !. | |
lengthAcc(List,I) :- | |
NewI is I+1, | |
getHelper(_,NewI) -> lengthAcc(List,NewI) ; getHelper(List,I). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment