MathGroup Archive 1992

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

Search the Archive

Re: Indexed Scan


>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