Clojure-How to add successive pairs in vector?

前端 未结 3 1887
小鲜肉
小鲜肉 2021-01-19 16:01

Trying to write a recursive function that adds successive pairs in a vector.

[1 2 3 4] => [3 5 7]

Pretty much stuck and this is what I h

3条回答
  •  情话喂你
    2021-01-19 16:14

    Here is another possible solution:

    (def tmp [1 2 3 4])
    
    (map + tmp (rest tmp))
    

提交回复
热议问题