What is the idiomatic way to swap two elements in a vector

牧云@^-^@ 提交于 2019-11-30 08:30:43

I can't think of a particularly elegant solution, either. Here's how I'd write it though:

(defn swap [v i1 i2] 
   (asso­c v i2 (v i1) i1 (v i2)))­
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!