MathGroup Archive 1997

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

Search the Archive

Re: Partition List

  • To: mathgroup at
  • Subject: [mg8430] Re: Partition List
  • From: tburton at (Tom Burton)
  • Date: Sat, 30 Aug 1997 00:42:39 -0400
  • Organization: Brahea Consulting
  • Sender: owner-wri-mathgroup at

On 26 Aug 1997 04:27:39 -0400, in comp.soft-sys.math.mathematica you

>A question on programing.
>I want to partition a list, using special values in the list as boundary
>indicators. For example, myList=3D{3,7,10,6,1,1,6,1,7,10,3,4,6} and my =
>value for boundary is 10, then my desired result would be
>How to do this using structure manipulating operators, and how to do it =
>pattern matching? Thanks.
Here's clumsy, slow method using pattern matching:

Run-time appears to be quadratic in the length of the list. I considered
tried to speed it up using nested lists and level-specific matching, but
then I timed my first attempt at structured programming:


This latter method is sooo much faster that I abandoned the first
approach. The latter method takes about 20 seconds on a list of one
million random integers (test case Table[Random[Integer,20],{1000000}]).
Run-time appears to be linear in the length of the list.  Cool.

PS: Not surprisingly, Extract seems to perform about as well as Take;
just leave in the second level of braces.
Tom Burton

  • Prev by Date: Re: Re: How to select unique elements in a list?
  • Next by Date: Re: Bra-Ket
  • Previous by thread: Re: Partition List
  • Next by thread: Re: Partition List