Question: I have a activity that select image on the android photo gallery

```
Intent intent = new Intent(Intent.Action_PICK, MediaStore.Images.Media.INTERNAL_OCNTENT_URI);

```

but I want to choose images from my android studio drawable folder instead.  

how should I modify the code?

[![enter image description here](https://i.stack.imgur.com/fa0NQ.png)](https://i.stack.imgur.com/fa0NQ.png)

Answer: 
You say your problem is that, if it didn't find the searched-for element, then it keeps adding 1 to the counter anyway. Well, that sounds like a perfectly good description of the problem: you add unconditionally, where you wish you added conditionally. So, just write a condition into your program, and don't add 1 if the result is -1:

```
posicionPrecioMayorA :: [Integer] -> Integer -> Integer
posicionPrecioMayorA [] a = (-1)
posicionPrecioMayorA (x:xs) a
    | x > a = 0
    | otherwise = case posicionPrecioMayorA xs a of
                    -1 -> -1
                    index -> 1 + index

```
You can create a helper function and keep track of the position you are at while recusring.

```hs
posicionPrecioMayorA :: [Integer] -> Integer -> Integer
posicionPrecioMayorA xs a = go xs a 0 where
  go [] _ _ = -1
  go (x:xs) a c
    | x > a = c
    | otherwise = go xs a (c+1)

```