You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find myself constantly re-implementing this function:
--| given a list of indices and a list, return the elements at those indices-- Assumes indices are sorted. If indices that are out of bounds are given,-- they are silently ignored.selectIndices:: [Int] -> [a] -> [a]
selectIndices indices list = go indices list 0where
go [] _ _ =[]
go _ [] _ =[]
go (index:indices) (x:xs) currentIndex
| index == currentIndex = x : go indices xs (currentIndex +1)
|otherwise= go (index:indices) xs (currentIndex +1)
Would you accept a PR for this?
The text was updated successfully, but these errors were encountered:
I really worry about the requirement for indices to be sorted - if you don't have that, it can't operate lazily, if you do have that, there is an easy to make mistake that is really hard to find. I don't really know a way to fix this API.
I find myself constantly re-implementing this function:
Would you accept a PR for this?
The text was updated successfully, but these errors were encountered: