Haskell replace element in list

后端 未结 4 1788
我在风中等你
我在风中等你 2020-12-31 01:31

Is there any built-in function to replace an element at a given index in haskell?

Example:

replaceAtIndex(2,\"foo\",[\"bar\",\"bar\",\"bar\"])

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 02:23

    There is actual arrays, but lists are really singly linked lists and the notion of replacing an element is not quite as obvious (and accessing an element at a given index may indicate that you shouldn't be using a list, so operations that might encourage it are avoided).

提交回复
热议问题