How can I find the indexes of an element in Haskell list

拈花ヽ惹草 提交于 2019-12-25 07:00:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!