Last active
October 17, 2022 22:00
-
-
Save GeoffChurch/81dd8224680d5b93111c131999df0a1a to your computer and use it in GitHub Desktop.
(Re-)implementation of SWI Prolog's copy_term/4 (https://github.com/SWI-Prolog/swipl-devel/commit/b4bfdc2e07b2638ded67421d354db6cd574a42e4), for use with pre-8.4.2 versions (https://swi-prolog.discourse.group/t/ann-swi-prolog-8-4-2-stable/5004)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copy_term(VarsIn, In, VarsOut, Out) :- | |
term_variables(In, AllVarsIn), | |
maplist(list_to_ord_set, [AllVarsIn, VarsIn], [AllVarsInOrdSet, VarsInOrdSet]), | |
ord_subtract(AllVarsInOrdSet, VarsInOrdSet, PreservedVars), | |
copy_term(PreservedVars-VarsIn-In, PreservedVars-VarsOut-Out). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment