interesting! thx guys!
On Sep 27, 10:45 am, Glen Rubin wrote:
> I have a vector of numbers
>
> [0 99 3334 53 2 5 99 2 55 63]
>
> I'd like to find the first index of a particular value. For example
> if the value was 99 then I want to return 1, b/c the index of 99 is
> 1. I can do this with a l
On Sep 27, 2010, at 9:45 AM, Glen Rubin wrote:
> I have a vector of numbers
>
> [0 99 3334 53 2 5 99 2 55 63]
>
> I'd like to find the first index of a particular value. For example
> if the value was 99 then I want to return 1, b/c the index of 99 is
> 1. I can do this with a loop/recur struc
Hi Glen,
Finding the *first* index isn't very Clojurish, what you want is to find *all*
the indexes, lazily. Then if you want the first one, just call first.
(use '[clojure.contrib.seq-utils :only (positions)])
(positions #{99} [0 99 3334 53 2 5 99 2 55 63])
-> (1 6)
Cheers,
Stu
> I have a vec
I have a vector of numbers
[0 99 3334 53 2 5 99 2 55 63]
I'd like to find the first index of a particular value. For example
if the value was 99 then I want to return 1, b/c the index of 99 is
1. I can do this with a loop/recur structure comparing each value in
the list to my desired value, how