Last active
August 29, 2015 14:21
-
-
Save ibratoev/ea66aa3ea2d4d49f0894 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
len_NM(L, N, M):- len_NM(L, 0, N, M). | |
lenght([],0). | |
lenght([_|T],R):- lenght(T, R1),R is R1+1. | |
len_NM([], X, N, _):- X >= N. | |
len_NM([A|L], X, N, M):- | |
lenght(A, AL), | |
AL >= M, | |
X1 is X+1, | |
len_NM(L, X1, N, M). | |
len_NM([A|L], X, N, M):- | |
lenght(A, AL), | |
AL < M, | |
len_NM(L, X, N, M). | |
len_NM_tests:- | |
len_NM([], 0, 0), | |
len_NM([[1]], 1, 1), | |
len_NM([[1], [1], [1, 2]], 1, 2), | |
not(len_NM([[1], [1], [1, 2]], 2, 2)), | |
not(len_NM([[1], [1], [1, 2]], 1, 3)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment