MathGroup Archive 2006

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

Search the Archive

Re: IntervalComplement


this seems to work okay for numeric intervals

In[1]:=
IntervalComplement[universe:Interval[{__?NumericQ}..],
    holes:Interval[{__?NumericQ}..]..]:=
  Module[{a,oth,tempResult,universeList=List@@universe,masks,
      unifiedHoles=IntervalUnion[holes]},
    masks=IntervalIntersection[Interval@#,unifiedHoles]&/@universeList;
    tempResult=
      IntervalUnion@@
        MapThread[
          Interval@@
              Partition[
                Block[{Interval=Sequence},Flatten@{#1[[1]],#2,#1[[-1]]}],
                2]&,{universeList,masks}];
    DeleteCases[tempResult,
      Alternatives@@IntervalIntersection[tempResult,unifiedHoles]]]

In[2]:=
IntervalComplement[Interval[{1,10},{11,12}],Interval[{2,3}],Interval[{4,5}]]
IntervalComplement[Interval[{1,10},{10.5,12}],Interval[{2,3},{4,5}],
  Interval[{8,11.5}]]

Out[2]=
Interval[{1,2},{3,4},{5,10},{11,12}]

Out[3]=
Interval[{1,2},{3,4},{5,8},{11.5,12}]

Unfortunately, I am not sure if I am going to use this any more...

On 10/12/06, Chris Chiasson <chris at chiasson.name> wrote:
> Has anyone implemented this function before? I need something that can do this.
>
> (IntervalComplement is to IntervalUnion as Complement is to Union)
>
> --
> http://chris.chiasson.name/
>


-- 
http://chris.chiasson.name/


  • Prev by Date: Re: IntervalComplement
  • Next by Date: RE:Beginner--[Please Help]How to get coefficient list issued from a Series Command
  • Previous by thread: Re: Re: IntervalComplement
  • Next by thread: Re: IntervalComplement