MathGroup Archive 1999

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

Search the Archive

Re: list manipulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20601] Re: list manipulation
  • From: "jim leddon" <jleddon at home.com>
  • Date: Tue, 2 Nov 1999 02:35:33 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Folks,

The program below takes the each value of the list,"events" , finds 
which of these values falls within the intervals {x,y} which comprise 
the list, "gaps" , then removes these values from the events list and 
outputs this modified list which is called "eout". I'm getting an error 
for incomplete expression, although I'm not sure if the algorithm itself 
is doing the job. These reason why I wrote the loop to cue on the 
integer parts of both lists is because these lists will eventually be 
quite large, about 3000 elements each in which case I wanted to make the 
process more efficient.

Thanks if anyone can help.
Debbie L.

gaps = {{1,5.5}, {2,4.3}, {2.7, 3.1}, {3.002, 4.007}, {10.001, 
10.007}, {10.101, 11.001}, {11.007, 12.0}};

events ={6.7, 8.9, 2.3, 2.789, 10, 11.002, 10.115, 3.02, 2.75};
eout = {0};
max = Length[events];
Do[e = IntegerPart[events[[i]]; ei = events[[i]]; tmp1 = 
Select[gaps,
                                                                    
#[[1]] >= IntegerPart[e] && #[[2]] <= IntegerPart[e] &];
                            For[ j=1, j<= Length[tmp1], j++,
                                        If[ ei <= tmp1[[j,2]] &&  ei .= tmp1[[j,1]],
                                        AppendTo[eout,ei]]
                                        ],
        {i,max}
    ]
Delete[eout,1];
eout



  • Next by Date: Re: BadAlgebra
  • Next by thread: Re: Re: list manipulation