]> Repositorios git - scryer-prolog.git/commitdiff
Move copy_term/3 to library(iso_ext)
authorAdrián Arroyo Calle <[email protected]>
Fri, 19 Jan 2024 16:33:45 +0000 (17:33 +0100)
committerAdrián Arroyo Calle <[email protected]>
Fri, 19 Jan 2024 16:33:45 +0000 (17:33 +0100)
src/lib/iso_ext.pl
src/machine/project_attributes.pl
src/toplevel.pl

index 15c05fd22cc646972bb5ad006e0d72793deca109..3e17f2180b8daf06f0458c6e0e357408423e25de 100644 (file)
@@ -17,7 +17,8 @@ but they're not part of the ISO Prolog standard at the moment.
                     succ/2,
                     call_nth/2,
                     countall/2,
-                    copy_term_nat/2]).
+                    copy_term_nat/2,
+                   copy_term/3]).
 
 :- use_module(library(error), [can_be/2,
                                domain_error/3,
@@ -26,6 +27,8 @@ but they're not part of the ISO Prolog standard at the moment.
 
 :- use_module(library(lists), [maplist/3]).
 
+:- use_module(library('$project_atts')).
+
 :- meta_predicate(forall(0, 0)).
 
 %% forall(Generate, Test).
@@ -382,3 +385,15 @@ countall(Goal, N) :-
 copy_term_nat(Source, Dest) :-
     '$copy_term_without_attr_vars'(Source, Dest).
 
+%% copy_term(+Term, -Copy, -Gs).
+%
+% Produce a deep copy of Term and unify it to Copy, without attributes.
+% Unify Gs with a list of goals that represent the attributes of Term.
+% Similar to `copy_term/2` but splitting the attributes.
+copy_term(Term, Copy, Gs) :-
+   can_be(list, Gs),
+   findall(Term-Rs, '$project_atts':term_residual_goals(Term,Rs), [Copy-Gs]),
+   (  var(Gs) ->
+      Gs = []
+   ;  true
+   ).
index f54797c83e37ca617edb0a7ec7a4a6f579711bff..1ad0c47fda560904b3317ac9352e3b18e77b9a14 100644 (file)
@@ -1,4 +1,4 @@
-:- module('$project_atts', [copy_term/3]).
+:- module('$project_atts', []).
 
 :- use_module(library(dcgs)).
 :- use_module(library(error), [can_be/2]).
@@ -100,14 +100,6 @@ gather_residual_goals([V|Vs]) -->
 
 delete_all_attributes_from_var(V) :- '$delete_all_attributes_from_var'(V).
 
-copy_term(Term, Copy, Gs) :-
-   can_be(list, Gs),
-   findall(Term-Rs, term_residual_goals(Term,Rs), [Copy-Gs]),
-   (  var(Gs) ->
-      Gs = []
-   ;  true
-   ).
-
 term_residual_goals(Term,Rs) :-
     '$term_attributed_variables'(Term, Vs),
     phrase(gather_residual_goals(Vs), Rs),
index 64340a9a0e316bd88f2186e8dc759d7d8bd65377..25ad94aa51fa609aab665d6860a57a3876e3e4d1 100644 (file)
@@ -1,4 +1,4 @@
-:- module('$toplevel', [copy_term/3]).
+:- module('$toplevel', []).
 
 :- use_module(library(atts), [call_residue_vars/2]).
 :- use_module(library(charsio)).