Swa*_* B. 6 haskell list-comprehension
有什么方法可以在下面的代码中知道x指向的当前元素的索引:
funcName k = [<current_index_here> | x <- list, x == k]
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激..谢谢:)
arr*_*owd 13
使用zip以下整数为每个元素编制索引:
funcName k = [if i == 2 then ... else ... | (i,x) <- zip [0..] list, x == k]
Run Code Online (Sandbox Code Playgroud)