[m-rev.] diff: svvarset.m
Julien Fischer
juliensf at cs.mu.OZ.AU
Tue Jan 25 14:43:43 AEDT 2005
Estimated hours taken: 0.5
Branches: main
library/svvarset.m:
Add state variable friendly versions of predicates from
varset that could benefit from it.
library/varset.m:
Improve a comment.
library/library.m:
NEWS
Mention the new module.
Julien.
Workspace:/home/earth/juliensf/ws53
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.366
diff -u -r1.366 NEWS
--- NEWS 24 Jan 2005 22:29:30 -0000 1.366
+++ NEWS 25 Jan 2005 03:24:38 -0000
@@ -26,8 +26,8 @@
set_ctree234, have been added to provide operations on sets with better
worst-case behavior (but worse constant factors) than the current
implementation.s Seven new modules, svarray, sveqvclass, svmap, svbimap,
- svset, svbag and svqueue now provide more convenient ways to update
- arrays, equivalence classes, maps, bimaps, sets, bags and queues
+ svset, svbag, svqueue and svvarset now provide more convenient ways to update
+ arrays, equivalence classes, maps, bimaps, sets, bags, queues and varsets
in code that uses state variables.
* New procedures have been added to many of the existing standard library
modules. Most notably, these include procedures for creating
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.83
diff -u -r1.83 library.m
--- library/library.m 21 Jan 2005 03:32:17 -0000 1.83
+++ library/library.m 25 Jan 2005 03:11:51 -0000
@@ -107,6 +107,7 @@
:- import_module svmap.
:- import_module svqueue.
:- import_module svset.
+:- import_module svvarset.
:- import_module term.
:- import_module term_io.
:- import_module term_to_xml.
Index: library/svvarset.m
===================================================================
RCS file: library/svvarset.m
diff -N library/svvarset.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ library/svvarset.m 25 Jan 2005 03:30:48 -0000
@@ -0,0 +1,107 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 2005 The University of Melbourne.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+% File: svvarset.m.
+
+% This file provides an interface to the 'varset' ADT that is conducive to the
+% use of state variable notation. The predicates here do the same thing as
+% their counterparts in the varset module; the only difference is the order of
+% the arguments.
+
+%--------------------------------------------------------------------------%
+
+:- module svvarset.
+:- interface.
+:- import_module list, set, string, term, varset.
+
+ % Create a new variable.
+ %
+:- pred svvarset__new_var(var(T)::out, varset(T)::in, varset(T)::out) is det.
+
+ % Create a new named variable.
+ %
+:- pred svvarset__new_named_var(string::in, var(T)::out,
+ varset(T)::in, varset(T)::out) is det.
+
+ % Create a new named variable with a unique (w.r.t. the
+ % varset) number appended to the name.
+ %
+:- pred svvarset__new_uniquely_named_var(string::in, var(T)::out,
+ varset(T)::in, varset(T)::out) is det.
+
+ % Create multiple new variables.
+ %
+:- pred svvarset__new_vars(int::in, list(var(T))::out, varset(T)::in,
+ varset(T)::out) is det.
+
+ % Delete the name and value for a variable.
+ %
+:- pred svvarset__delete_var(var(T)::in, varset(T)::in, varset(T)::out) is det.
+
+ % Delete the names and values for a list of variables.
+ %
+:- pred svvarset__delete_vars(list(var(T))::in, varset(T)::in, varset(T)::out)
+ is det.
+
+ % Set the name of a variable.
+ %
+:- pred svvarset__name_var(var(T)::in, string::in, varset(T)::in, varset(T)::out)
+ is det.
+
+ % Bind a value to a variable.
+ % This will overwrite any existing binding.
+ %
+:- pred svvarset__bind_var(var(T)::in, term(T)::in, varset(T)::in,
+ varset(T)::out) is det.
+
+ % Bind a set of terms to a set of variables.
+ %
+:- pred svvarset__bind_vars(substitution(T)::in, varset(T)::in, varset(T)::out)
+ is det.
+
+ % Given a varset and a set of variables, remove the names
+ % and values of any other variables stored in the varset.
+ %
+:- pred svvarset__select(set(var(T))::in, varset(T)::in, varset(T)::out) is det.
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+svvarset__new_var(Var, Varset0, Varset) :-
+ varset__new_var(Varset0, Var, Varset).
+
+svvarset__new_named_var(Name, Var, Varset0, Varset) :-
+ varset__new_named_var(Varset0, Name, Var, Varset).
+
+svvarset__new_uniquely_named_var(Name, Var, Varset0, Varset) :-
+ varset__new_uniquely_named_var(Varset0, Name, Var, Varset).
+
+svvarset__new_vars(NumVars, NewVars, Varset0, Varset) :-
+ varset__new_vars(Varset0, NumVars, NewVars, Varset).
+
+svvarset__delete_var(Var, Varset0, Varset) :-
+ varset__delete_var(Varset0, Var, Varset).
+
+svvarset__delete_vars(Vars, Varset0, Varset) :-
+ varset__delete_vars(Varset0, Vars, Varset).
+
+svvarset__name_var(Id, Name, Varset0, Varset) :-
+ varset__name_var(Varset0, Id, Name, Varset).
+
+svvarset__bind_var(Id, Val, Varset0, Varset) :-
+ varset__bind_var(Varset0, Id, Val, Varset).
+
+svvarset__bind_vars(Subst, Varset0, Varset) :-
+ varset__bind_vars(Varset0, Subst, Varset).
+
+svvarset__select(Vars, Varset0, Varset) :-
+ varset__select(Varset0, Vars, Varset).
+
+%-----------------------------------------------------------------------------%
+:- end_module svvarset.
+%-----------------------------------------------------------------------------%
Index: library/varset.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/varset.m,v
retrieving revision 1.72
diff -u -r1.72 varset.m
--- library/varset.m 24 Jan 2005 23:16:40 -0000 1.72
+++ library/varset.m 25 Jan 2005 02:51:24 -0000
@@ -108,8 +108,8 @@
%
:- pred varset__search_name(varset(T)::in, var(T)::in, string::out) is semidet.
- % Bind a value to a variable
- % (will overwrite any existing binding).
+ % Bind a value to a variable.
+ % This will overwrite any existing binding.
%
:- func varset__bind_var(varset(T), var(T), term(T)) = varset(T).
:- pred varset__bind_var(varset(T)::in, var(T)::in, term(T)::in,
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list