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

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

Search the Archive

Re: Position of Sign change in long list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18765] Re: [mg18691] Position of Sign change in long list
  • From: "Hermann Meier" <hmeier at webshuttle.ch>
  • Date: Tue, 20 Jul 1999 01:33:26 -0400
  • Organization: EUnet AG
  • References: <199907150546.BAA15968@smc.vnet.net.> <7mr4ua$8lg$1@dragonfly.wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

The built-in function Position may be used:

Module[{s = Sign[test], s1, cc}, s1 = First[s];
    Position[s, cc_ /; cc != s1, 1, 1] // First // First] // Timing


HM

>> test=Table[Sin[Pi i/5000. +1],{i,10000}];


>> With[{st=Sign[test]},Length[Split[st][[1]]]]
>>
>> If you can think of a still faster or more elegant solution please let me
>> know!
>>
>> Martin
>
>
>






  • Prev by Date: Re: Is there a FAQ? (Clear all)
  • Next by Date: Re: Is there a FAQ? (Clear all)
  • Previous by thread: Re: Position of Sign change in long list
  • Next by thread: Re: Position of Sign change in long list