<commit_before>/*  $Id$

    Copyright (c) 1990 <NAME>. All rights reserved.
    <EMAIL>

    Purpose: calling predicates
*/

:- module($apply, [
	checklist/2, 
	maplist/3, 
	sublist/3, 
	forall/2]).

:- module_transparent
	checklist/2, 
	checklist2/2, 
	maplist/3, 
	maplist2/3, 
	sublist/3, 
	forall/2.

%	checklist(+Goal, +List)
%
%	True if Goal can succesfully be applied on all elements of List.
%	Arguments are reordered to gain performance as well as to make
%	the predicate deterministic under normal circumstances.

checklist(Goal, List) :-
	checklist2(List, Goal).

checklist2([], _).
checklist2([Elem|Tail], Goal) :-
	call(Goal, Elem), 
	checklist2(Tail, Goal).

%	maplist(+Goal, +List1, ?List2)
%	True if Goal can succesfully be applied to all succesive pairs
%	of elements of List1 and List2.

maplist(Goal, List1, List2) :-
	maplist2(List1, List2, Goal).

maplist2([], [], _).
maplist2([Elem1|Tail1], [Elem2|Tail2], Goal) :-
	call(Goal, Elem1, Elem2), 
	maplist2(Tail1, Tail2, Goal).

%	sublist(+Goal, +List1, ?List2)
%	Succeeds if List2 unifies with a list holding those terms for wich
%	apply(Goal, Elem) succeeds.

sublist(_, [], []) :- !.
sublist(Goal, [H|T], Sub) :-
	call(Goal, H), !, 
	Sub = [H|R], 
	sublist(Goal, T, R).
sublist(Goal, [_|T], R) :-
	sublist(Goal, T, R).

%	forall(+Condition, +Action)
%	True if Action if true for all variable bindings for which Condition
%	if true.

forall(Cond, Action) :-
	\+ (Cond, \+ Action).
<commit_msg>* Started call_cleanup/0, but abandoned<commit_after>/*  $Id$

    Copyright (c) 1990 <NAME>. All rights reserved.
    <EMAIL>

    Purpose: calling predicates
*/

:- module($apply, [
	checklist/2, 
	maplist/3, 
	sublist/3, 
	forall/2]).

:- module_transparent
	checklist/2, 
	checklist2/2, 
	maplist/3, 
	maplist2/3, 
	sublist/3, 
	forall/2.

%	checklist(+Goal, +List)
%
%	True if Goal can succesfully be applied on all elements of List.
%	Arguments are reordered to gain performance as well as to make
%	the predicate deterministic under normal circumstances.

checklist(Goal, List) :-
	checklist2(List, Goal).

checklist2([], _).
checklist2([Elem|Tail], Goal) :-
	call(Goal, Elem), 
	checklist2(Tail, Goal).

%	maplist(+Goal, +List1, ?List2)
%	True if Goal can succesfully be applied to all succesive pairs
%	of elements of List1 and List2.

maplist(Goal, List1, List2) :-
	maplist2(List1, List2, Goal).

maplist2([], [], _).
maplist2([Elem1|Tail1], [Elem2|Tail2], Goal) :-
	call(Goal, Elem1, Elem2), 
	maplist2(Tail1, Tail2, Goal).

%	sublist(+Goal, +List1, ?List2)
%	Succeeds if List2 unifies with a list holding those terms for wich
%	apply(Goal, Elem) succeeds.

sublist(_, [], []) :- !.
sublist(Goal, [H|T], Sub) :-
	call(Goal, H), !, 
	Sub = [H|R], 
	sublist(Goal, T, R).
sublist(Goal, [_|T], R) :-
	sublist(Goal, T, R).

%	forall(+Condition, +Action)
%	True if Action if true for all variable bindings for which Condition
%	if true.

forall(Cond, Action) :-
	\+ (Cond, \+ Action).

%	call_cleanup(:Goal, :Cleanup)
%
%	Calls Goal as call/1 and executes Cleanup whenever Goal finishes
%	due to deterministic success, failure, exception or cut.

{'fraction_non_alphanumeric': 0.1533525826114854, 'fraction_numerical': 0.02823227462303497, 'mean_word_length': 3.9728867623604467, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7097115', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1250, 'n_words': 340}