Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*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 1992

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

Search the Archive

Re: Indexed Scan

  • To: mathgroup <mathgroup at yoda.physics.unc.edu>
  • Subject: Re: Indexed Scan
  • From: HAY at leicester.ac.uk
  • Date: Fri, 10 JUL 92 16:28:16 GMT

>I have found a method to return an index value from the scanning of an list.
>In fact, is impossible to know the "place" where Scan yield to some desirable
>result.

>Another functions like, Position or Select only work with pattern, no
>functions and then they can not return values or stop themself until they
>finish with the array.

>In[]
>  yt=Sin /@ Range[0,10,.5];
>In[]
>  c=0;Scan[If[(c++;# < 0),Return[c]]&, yt]
>Out[]
>  8

We can use all 4 slots for Position:
               Position[expr, pattern, listspec, howmany]

In[]
    Position[yt,x_/;x<0 ,{1}, 1][[1,1]]
Out[]
    8

Allan Hayes
Department of Mathematics
The University
Leicester LE1 7RH
U.K.
Tel: 0533-714198
hay at leicester.ac.uk 





  • Prev by Date: teaching
  • Next by Date: Re: Rule and First
  • Previous by thread: Re: Indexed Scan
  • Next by thread: time series