Skip to content

Instantly share code, notes, and snippets.

@ibratoev
Last active August 29, 2015 14:21
Show Gist options
  • Save ibratoev/ea66aa3ea2d4d49f0894 to your computer and use it in GitHub Desktop.
Save ibratoev/ea66aa3ea2d4d49f0894 to your computer and use it in GitHub Desktop.
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