amalgame/commit
simplify code by using apply:partition/4
author | Jacco van Ossenbruggen |
---|---|
Fri Sep 6 15:49:40 2013 +0200 | |
committer | Jacco van Ossenbruggen |
Fri Sep 6 15:49:40 2013 +0200 | |
commit | 3e0d152becc373fe90c16bfe60ca02270281a524 |
tree | c49a3277fb60ad957b7829943f5325c39883a91f |
parent | b437188e9e3334c339ff4dc276117f9777f38fa4 |
Diff style: patch stat
diff --git a/lib/ag_modules/ancestor_match.pl b/lib/ag_modules/ancestor_match.pl index 765d31a..f627164 100644 --- a/lib/ag_modules/ancestor_match.pl +++ b/lib/ag_modules/ancestor_match.pl @@ -4,7 +4,6 @@ :- use_module(library(semweb/rdf_db)). :- use_module(library(amalgame/vocabulary)). :- use_module(library(amalgame/map)). -:- use_module(string_match_util). :- public amalgame_module/1. :- public filter/3. @@ -115,7 +114,7 @@ selecter_(Type, [Head|Tail], BackgroundMatches, Sel, Dis, Und, Options) :- Candidates = [Head|Same], maplist(ancestor_count(BackgroundMatches, Options), Candidates, Counts0), keysort(Counts0, Counts), - zero_keys(Counts, Zero, NonZero), + partition(=(0-_), Counts, Zero, NonZero), ( NonZero \= [] -> pairs_values(Zero, DisgardedSame), pairs_values(NonZero, SelectedSame), diff --git a/lib/ag_modules/descendent_match.pl b/lib/ag_modules/descendent_match.pl index 5585e64..77f830d 100644 --- a/lib/ag_modules/descendent_match.pl +++ b/lib/ag_modules/descendent_match.pl @@ -4,7 +4,6 @@ :- use_module(library(semweb/rdf_db)). :- use_module(library(amalgame/vocabulary)). :- use_module(library(amalgame/map)). -:- use_module(string_match_util). :- public amalgame_module/1. :- public filter/3. @@ -116,7 +115,7 @@ selecter_(Type, [Head|Tail], BackgroundMatches, Sel, Dis, Und, Options) :- Candidates = [Head|Same], maplist(descendent_count(BackgroundMatches, Options), Candidates, Counts0), keysort(Counts0, Counts), - zero_keys(Counts, Zero, NonZero), + partition(=(0-_), Counts, Zero, NonZero), ( NonZero \= [] -> pairs_values(Zero, DisgardedSame), pairs_values(NonZero, SelectedSame), diff --git a/lib/ag_modules/string_match_util.pl b/lib/ag_modules/string_match_util.pl index 6ec8d80..4477090 100644 --- a/lib/ag_modules/string_match_util.pl +++ b/lib/ag_modules/string_match_util.pl @@ -1,7 +1,6 @@ :- module(ag_string_match_util, [label_list/1, - matching_types/2, - zero_keys/3 + matching_types/2 ]). :- use_module(library(semweb/rdf_db)). @@ -45,13 +44,3 @@ matching_types(S1, S2) :- ; true) ,!. -%% zero_keys(+Pairs, -ZeroKeyPairs, -NonZeroKeyPairs) is det. -% -% Pairs is a keysorted list of pairs with nonneg integer keys, -% which is partioned in a list of zero key pairs and non-zero key -% pairs. -zero_keys([], [], []) :- !. -zero_keys([0-Value|Tail], [0-Value|ZeroTail], NonZeroTail) :- - !, - zero_keys(Tail, ZeroTail, NonZeroTail). -zero_keys(Pairs, [], Pairs) :- !.