问题
Here is a Haskell list:
[[1],[3,5],[],[1,9],[3,5],[9,7],[1,9]]
I want to find the exact index of its elements. I tried to use elemIndex
but it doesn't give the correct index when I try to find duplicated element like [3,5]
and [1,9]
.
回答1:
Is this what you want?
> elemIndices [3,5] [[1],[3,5],[],[1,9],[3,5],[9,7],[1,9]]
[1,4]
来源:https://stackoverflow.com/questions/27514828/how-can-i-find-the-indexes-of-an-element-in-haskell-list