Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*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 2002

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

Search the Archive

Re: List processing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37244] Re: [mg37196] List processing
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Fri, 18 Oct 2002 05:17:15 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is a version which compresses the list going forward, it does not  
seem to be significantly faster than the other version but the memory  
use should be slightly smaller:

(*Handle some degenerate cases here *)

fcompress[{}]:={};

(*This pattern is the stopping point of the recursion*)

fcompress[lst:{{_?NumericQ,_?NumericQ}}]:=lst

(*This function needs to be called with a sorted list*)
fcompress[lst:{{_?NumericQ,_?NumericQ}..}]:=With[{rng1=lst[[1]],rng2=lst 
[[2]]},If[rng1[[2]]<rng2[[1]],{rng1,Sequence@@fcompress[Rest[lst]]},fcom 
press[Join[{{rng1[[1]],Max[{rng1[[2]],rng2[[2]]}]}},Drop[lst,2]]]]]

Regards,

Sseziwa



  • Prev by Date: Bad Alignment of Y Axes
  • Next by Date: Re: List processing
  • Previous by thread: Re: Re: List processing
  • Next by thread: Re: List processing