Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,25 @@
% fetch all the subsequences
ncsubs(L, LNCSL) :-
setof(NCSL, one_ncsubs(L, NCSL), LNCSL).
% how to build one subsequence
one_ncsubs(L, NCSL) :-
extract_elem(L, NCSL);
( sublist(L, L1),
one_ncsubs(L1, NCSL)).
% extract one element of the list
% this element is neither the first nor the last.
extract_elem(L, NCSL) :-
length(L, Len),
Len1 is Len - 2,
between(1, Len1, I),
nth0(I, L, Elem),
select(Elem, L, NCS1),
( NCSL = NCS1; extract_elem(NCS1, NCSL)).
% extract the first or the last element of the list
sublist(L, SL) :-
(L = [_|SL];
reverse(L, [_|SL1]),
reverse(SL1, SL)).

View file

@ -0,0 +1,2 @@
?- ncsubs([a,e,i,o,u], L).
L = [[a,e,i,u],[a,e,o],[a,e,o,u],[a,e,u],[a,i],[a,i,o],[a,i,o,u],[a,i,u],[a,o],[a,o,u],[a,u],[e,i,u],[e,o],[e,o,u],[e,u],[i,u]]