How can I remove an item from a sequence in Clojure?

前端 未结 3 2112
自闭症患者
自闭症患者 2020-12-08 07:23

First, I assume each structure-specific sequences would have different ways to remove an item: Vectors could be by index, List could be remove first or las

3条回答
  •  被撕碎了的回忆
    2020-12-08 07:28

    As an extension of Brian Carper's answer. It depends on what you will be doing with the result. If you are passing the result to something that wants to work on the entire set of data (ie to print it) It is idiomatic to make a seq and use filter or remove to solve the problem lazily. If on the other hand you are modifying the data structure to save for various later uses then creating a seq on it would loose its favorable update characteristics so in this case its better to use the update function specific to that data structure.

提交回复
热议问题