MathGroup Archive 1998

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

Search the Archive

Re: Re: Re: logical inconsistency in Union

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13256] Re: [mg13194] Re: [mg13109] Re: [mg13069] logical inconsistency in Union
  • From: David Withoff <withoff>
  • Date: Fri, 17 Jul 1998 03:17:50 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> Hi David,
>
> this union1 is so awfully slow, so I tried to speed it up a bit. I
> suppos~d
> that two elements are considered equal if they give the same result to a
> criterion crit. My union4 is quite a bit faster even than union3 of
> Union.html.
>
> union4[p_List,crit_]:= Module[{result,link,new},
>   result = link[];
>   new[_] = True;
>  Table[If[new[crit[p[[n]]]],new[crit[p[[n]]]]= False;
>         result=link[result,p[[n]]]],{n,Length[p]}];
>   List@@Flatten[result,\[Infinity],link]]
>
> I hope you like it.
>
> J|rgen

This is an interesting definition, but it doesn't implement the same
functionality as the other functions, speed comparisons aren't very
meaningful.  The test function "crit" in the definition of union4 isn't
a general comparison function.  It takes one argument, not two, and so
doesn't provide for general comparison of elements as in the value of
the SameTest option in Union.  The comparison test that is effectively
used here is the comparison that is used inside Mathematica to decide
whether or not to apply a rule, after applying the value of "crit" to
each expression.

This program really does illustrate an interesting strategy, but it
isn't a general Union function.

Dave Withoff
Wolfram Research


  • Prev by Date: In which interval?
  • Next by Date: Tree plotting package?
  • Previous by thread: Re: Re: logical inconsistency in Union
  • Next by thread: Re: Re: Re: Re: logical inconsistency in Union