MathGroup Archive 1999

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

Search the Archive

Re: Re: modified list interval calculation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21198] Re: [mg21058] Re: modified list interval calculation
  • From: BobHanlon at aol.com
  • Date: Fri, 17 Dec 1999 01:24:35 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I don't understand your rules. Why is 9 removed but not 12 and all 
subsequent numbers since they would also involve operations with 
removed numbers? Without understanding your rules, I cannot provide 
your results; however, this should give you some ideas.

t = {1, 4, 4.5, 6, 7, 8, 8.9, 9, 10, 12, 140, 16, 16.8, 17, 18, 19, 19.1, 
      19.3, 19.5, 20};

nt = {8, 8.9, 10, 17};

Select[t, ! MemberQ[nt, #] &]

{1, 4, 4.5, 6, 7, 9, 12, 140, 16, 16.8, 18, 19, 19.1, 19.3, 19.5, 20}

Partition[%, 2, 1]

{{1, 4}, {4, 4.5}, {4.5, 6}, {6, 7}, {7, 9}, {9, 12}, {12, 140}, {140, 
    16}, {16, 16.8}, {16.8, 18}, {18, 19}, {19, 19.1}, {19.1, 19.3}, {19.3, 
    19.5}, {19.5, 20}}

% /. {a_, b_} :> b - a

{3, 0.5, 1.5, 1, 2, 3, 128, -124, 0.8, 1.2, 1, 0.1, 0.2, 0.2, 0.5}

Combining these steps

Partition[Select[t,  !MemberQ[nt, #1] & ], 2, 1] /. 
  {a_, b_} :> b - a

{3, 0.5, 1.5, 1, 2, 3, 128, -124, 0.8, 1.2, 1, 0.1, 0.2, 0.2, 0.5}

Bob Hanlon

In a message dated 12/13/1999 1:30:18 AM, Dleddon at students.cas.unt.edu writes:

>I am having trouble with the problem below:
>
>I am trying to remove from list, t, those numbers in list, nt, that 
>match and then I want to calculate the differences (intervals ) 
>between succesive numbers in list, t, that do not contain the 
>removed number. For example:
>the two lists are;
>t = {1,4,4.5,6,7,8,8.9,9,10,12,140,16,16.8,17,18,
>   19,19.1,19.3,19.5,20}
>nt = {8,8.9,10,17}
>
>the resulting intervals would look like:
>4 -1, 4.5 - 4, 6 - 4.5, 7 - 6, 140 -12, 16 - 140, 16.8 - 16, 19 - 18,
>19.1 -19, 19.3 - 19.1, 19.5 - 19.3, 20 - 19.5
>and of course the final list would be:
>intervals = {3, .5, 1.5, 1, 128, -124, .8, 1, .1, .2, .2, .5};
>
>Note that 9 was omitted from the calculation of intervals because it 
>would have been involved in a calculation with a removed number 
>from the list, t. 
>


  • Prev by Date: Re: 2 coupled diff. eqns
  • Next by Date: Re: Partial evaluation
  • Previous by thread: Re: Re: modified list interval calculation
  • Next by thread: Re: Re: modified list interval calculation