Remove elements by index in haskell

后端 未结 8 886

I\'m new in haskell and I\'m looking for some standard functions to work with lists by indexes.

My exact problem is that i want to remove 3 elements after every 5. If i

8条回答
  •  广开言路
    2021-02-07 23:37

    Since nobody did a version with "unfoldr", here is my take:

    drop3after5 lst = concat $ unfoldr chunk lst
      where
        chunk [] = Nothing
        chunk lst = Just (take 5 lst, drop (5+3) lst)
    

    Seems to be the shortest thus far

提交回复
热议问题