How to split a sequence into every 3 adjacent elements in clojure?

For a sequence such as:

[1 2 3 4 5 6] 

How to split it into every 3 neighboring elements in clojure? Similar:

 ([1 2 3] [2 3 4] [3 4 5] [4 5 6]) 

Preferred functions in clojure.core!

+4
source share
1 answer

See partition :

 user=> (partition 3 1 [1 2 3 4 5 6]) ((1 2 3) (2 3 4) (3 4 5) (4 5 6)) 
+12
source

Source: https://habr.com/ru/post/1434791/


All Articles