I currently have a list of numbers, and I want to know which of these numbers are within a certain range, and what their position is in the list.
I'm reasonably new to pari so I'm not sure how exactly to go about this.
For a simplistic example of what I'm doing:
Find the inverses of the numbers 1 to 20 which lie within the range 0.05 and 0.15
I've set up a list like this:
A=[1/i|i<-[1..20]];
From here, I'd like a list of all the i so that A[i] is in that range.
But I'm not sure how to proceed from here. I tried some simple if/for statements, but these weren't working.
How exactly would I try and go about something like this?
You want to use select
:
Either:
select(i->A[i]>=0.05 && A[i]<=0.15, [1..#A])
Or more compactly using the flag 1 to return indices:
select(v->v>=0.05 && v<=0.15, A, 1)