Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: IntervalComplement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70321] Re: IntervalComplement
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Fri, 13 Oct 2006 01:30:01 -0400 (EDT)
  • References: <acbec1a40610120129t65e74a60r8a60a90aa650dd51@mail.gmail.com>

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