Clojure 的惯用方式是什么take-while-and-n-more
:
=> (take-while-and-n-more #(<= % 3) 1 (range 10))
(0 1 2 3 4)
我的尝试是:
(defn take-while-and-n-more [pred n coll]
(let
[take-while-result (take-while pred coll)
n0 (count take-while-result)]
(concat
take-while-result
(into [] (take n (drop n0 coll))))))