I am trying to find a solution to a problem i am facing at the moment, i have tried and tried to get this working but to no avail. I am trying to scan a list containing data and then returning the position of the data if found.
For example if i ran this:
(ind 'p '(l m n o p o p))
Then i would get a return value of....
==> 4 6
As it has found the data in those positions.
I have come close i think to what i want with this solution before, but i cannot get it to run. Can anyone help me figure out whats up with my function?? As far as i can see it should work, but i cant figure out why it isnt?
(defn ind
([choice list emptylist x]
(let [x (count list)])
(if (= (x) 0)
nil)
(if (= (first list) item)
(ind item (rest list) (cons x emptylist) (dec x))
(ind item (rest list) emptylist (dec x))
)
)
)
What i have tried to do is loop through the list until it hits a value and add it to the empty list and once it has looped through return the empty list.