From ab8cc85adde879fb963c94d15675783f2cf4b183 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Tue, 14 Aug 2007 05:14:52 +0000 Subject: Initial population. --- src/hyper/pages/MSET.ht | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/hyper/pages/MSET.ht (limited to 'src/hyper/pages/MSET.ht') diff --git a/src/hyper/pages/MSET.ht b/src/hyper/pages/MSET.ht new file mode 100644 index 00000000..381d9356 --- /dev/null +++ b/src/hyper/pages/MSET.ht @@ -0,0 +1,95 @@ +% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved. +% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk. +\newcommand{\MultiSetXmpTitle}{MultiSet} +\newcommand{\MultiSetXmpNumber}{9.53} +% +% ===================================================================== +\begin{page}{MultiSetXmpPage}{9.53 MultiSet} +% ===================================================================== +\beginscroll +The domain \spadtype{Multiset(R)} is similar to \spadtype{Set(R)} +except that multiplicities +(counts of duplications) are maintained and displayed. +Use the operation \spadfunFrom{multiset}{Multiset} to create +%-% \HDindex{set!vs. multiset}{MultiSetXmpPage}{9.53}{MultiSet} +multisets from lists. +%-% \HDindex{multiset}{MultiSetXmpPage}{9.53}{MultiSet} +All the standard operations from sets are available for +multisets. +An element with multiplicity greater than one has the +multiplicity displayed first, then a colon, and then the element. + +\xtc{ +Create a multiset of integers. +}{ +\spadpaste{s := multiset [1,2,3,4,5,4,3,2,3,4,5,6,7,4,10]\bound{s}} +} +\xtc{ +The operation \spadfunX{insert} adds an element to a multiset. +}{ +\spadpaste{insert!(3,s)\bound{s1}\free{s}} +} +\xtc{ +Use \spadfunX{remove} to remove an element. +If a third argument is present, it specifies how many instances +to remove. Otherwise all instances of the element are removed. +Display the resulting multiset. +}{ +\spadpaste{remove!(3,s,1); s\bound{s2}\free{s1}} +} +\xtc{ +}{ +\spadpaste{remove!(5,s); s\bound{s2}\free{s1}} +} +\xtc{ +The operation \spadfun{count} returns the number of copies +of a given value. +}{ +\spadpaste{count(5,s)\free{s2}} +} +\xtc{ +A second multiset. +}{ +\spadpaste{t := multiset [2,2,2,-9]\bound{t}} +} +\xtc{ +The \spadfun{union} of two multisets is additive. +}{ +\spadpaste{U := union(s,t)\bound{U}} +} +\xtc{ +The \spadfun{intersect} operation gives the elements that are in +common, with additive multiplicity. +}{ +\spadpaste{I := intersect(s,t)\bound{I}} +} +\xtc{ +The \spadfun{difference} of \spad{s} and \spad{t} consists of +the elements that \spad{s} has but \spad{t} does not. +Elements are regarded as indistinguishable, so that if \spad{s} +and \spad{t} have any element in common, the \spadfun{difference} +does not contain that element. +}{ +\spadpaste{difference(s,t)\free{s2 t}} +} +\xtc{ +The \spadfun{symmetricDifference} is the \spadfun{union} +of \spad{difference(s, t)} and \spad{difference(t, s)}. +}{ +\spadpaste{S := symmetricDifference(s,t)\bound{S}\free{s2 t}} +} +\xtc{ +Check that the \spadfun{union} of the \spadfun{symmetricDifference} and +the \spadfun{intersect} equals the \spadfun{union} of the elements. +}{ +\spadpaste{(U = union(S,I))@Boolean\free{S I U}} +} +\xtc{ +Check some inclusion relations. +}{ +\spadpaste{t1 := multiset [1,2,2,3]; [t1 < t, t1 < s, t < s, t1 <= s]\free{t s2}} +} +\endscroll +\autobuttons +\end{page} +% -- cgit v1.2.3