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