How can I rewrite this Ruby code in Clojure?
seq = [1, 2, 3, 4, 5].each_cons(2) #=> lazy Enumerable of pairs seq.to_a => [[1, 2], [2, 3], [3, 4], [4, 5]]
Clojure:
(??? 2 [1 2 3 4 5]) ;=> lazy seq of [1 2] [2 3] [3 4] [4 5]
What you are asking for is called a sliding window in a lazy sequence. That way you can achieve this
user=> (partition 2 1 [1 2 3 4 5]) ((1 2) (2 3) (3 4) (4 5))
Source: https://habr.com/ru/post/952896/More articles:How to force release on iOS - memory-managementTime functions in mingw - c ++How to set axis spacing range using Matplotlib or other libraries in python - pythonFind Indexes from a List in Elixir - arraysCUDA: Why is it impossible to define static global member functions? - c ++ActiveAdmin automatically downloads full connection table - ruby-on-railsHow to rewrite Ruby `Array (x)` in Clojure? - clojureAndroid - only the file with the opened error - javaWhy doesn't Chromecast take into account fractional values โโof Rate playback on video elements? - chromecastFinding the path with the maximum minimum capacity in the graph - algorithmAll Articles