Commit 07946017 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Add a separate_list tool and fix extract_list

parent 8d8fe677
......@@ -32,6 +32,7 @@
check_cleaned/1,
join_with_op/3,
extract_sublist/2,
separate_list/4,
uppercase_char/1,
lowercase_char/1,
alphabetic_char/1,
......@@ -511,6 +512,12 @@ join_with_op([I1, I2 | Items], Op, Term) :-
join_with_op([I2 | Items], Op, T).
%! extract_sublist(+List, -SubList)
%
% generates all sublists of List
extract_sublist([],[]).
extract_sublist([H | T], [H | TT]) :-
extract_sublist(T, TT).
......@@ -518,6 +525,16 @@ extract_sublist([_ | T], TT) :-
extract_sublist(T, TT).
%! separate_list(+List12, +N, -List1, -List2)
%
% separate a list in two at a predefined length
% may also be used to extract the N first elements of a list
separate_list(List12, N, List1, List2) :-
length(List1, N),
append(List1, List2, List12).
uppercase_char(Char) :-
Char @>= 'A', Char @=< 'Z'.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment