如何获得序列clojure的尾巴

har*_*man 7 functional-programming clojure clojurescript

我有他们的咒语序列

(1 2 3 4) 
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到序列的所有尾部

((1 2 3 4) (2 3 4) (3 4) (4) ())
Run Code Online (Sandbox Code Playgroud)

ez1*_*1sl 13

获得所有尾巴的另一种方法是使用该reductions函数.

user=> (def x '(1 2 3 4))
#'user/x
user=> (reductions (fn [s _] (rest s)) x x)
((1 2 3 4) (2 3 4) (3 4) (4) ())
user=> 
Run Code Online (Sandbox Code Playgroud)