动力:我是在 python 中寻找一些能让我得到的东西
f([1,2,3]) == [[1,2,3], [2,3], [3]]
在 clojure 中,这只是 (nest rest #(not (empty? %)) lst)
,或者如果我们有一个 nest 函数,它也可以。我们要不要?我厌倦了盯着 clojure api 列表..
在 python 或 clojure 中更好的方法也将不胜感激..
最佳答案
data = [1,2,3]
result = [ data[i:] for i in range(len(data)) ]
关于python/clojure 相当于 mathematica 的 NestWhileList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5293176/