MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

DistinctElements.m package


MathGroup users:

I've completed writing a general "Union" package which I call
DistinctElements.m. It contain two functions 

In[14]:=
?DistinctElements

"DistinctElements[listA,sameTestQ] returns a list of distinct elements in \
listA, based on sameTestQ. sameTestQ must accept two arguments and return \
either True or False. listA can have head other than List. In order for \
DistinctElements to return truely distinct elements where \
sameTestQ[a,b]==False for any ordered pairs a,b in the result, sameTestQ
must \
be orderless and transitive: (1) sameTestQ[a,b]==sameTestQ[b,a], (2) if \
sameTestQ[a,b], sameTestQ[b,c], then sameTestQ[a,c]. Usage Example: \
DistinctElements[Permutations[Range at 3],Function[#1==Reverse at #2]]"

In[15]:=
?EquivalenceIndex

"EquivalenceIndex[listA,sameTestQ] returns a partition of indexes, e.g. \
{{1,4,7},{2},{3,10},{5,8},{6,9}}, of listA. Index of elements that are \
considered equivalent under sameTestQ are grouped together. sameTestQ must \
accept two arguments and return either True or False. ListA can have head \
other than List. To guarantee that sameTestQ[listA[[e]],listA[[f]]]==False \
for any e,f in distinct index grouping, sameTestQ must be orderless and \
transitive: (1) sameTestQ[a,b]==sameTestQ[b,a], (2) if sameTestQ[a,b], \
sameTestQ[b,c], then sameTestQ[a,c]. Usage Exapmle: \
EquivalenceIndex[Permutations[Range at 3],Function[#1==Reverse at #2]]"

Comes with full documentation and usage examples. I think it'd be useful to
some mma programers. Download it at:
<http://www.best.com/~xah/SpecialPlaneCurves_dir/MmaPackages_dir/mmaPackages
.html>

Send me comments & suggestions. I'll upload it to MathSource after a month.
Thanks.

 Xah, xah at best.com, http://www.best.com/~xah/
 Symantec Visual Cafe. Windows95/NT. CD-ROM. Factory Sealed. $50. email me.


  • Prev by Date: Re: About PolynomialDivision & the Notebook Frontend
  • Next by Date: Re: f + g
  • Previous by thread: Re: About PolynomialDivision & the Notebook Frontend
  • Next by thread: Re: f + g