1.3.0 permalink Arrow_down_16x16

take-last

clojure.core

  • (take-last n coll)
Returns a seq of the last n items in coll. Depending on the type
of coll may be no better than linear time. For vectors, see also subvec.

1 Example top

  • user=> (take-last 2 [1 2 3 4])
    (3 4)
    
    user=> (take-last 2 [4])
    (4)
    
    user=> (take-last 2 [])
    nil
    
    user=> (take-last 2 nil)
    nil
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2532 top

(defn take-last
  "Returns a seq of the last n items in coll.  Depending on the type
  of coll may be no better than linear time.  For vectors, see also subvec."
  {:added "1.1"
   :static true}
  [n coll]
  (loop [s (seq coll), lead (seq (drop n coll))]
    (if lead
      (recur (next s) (next lead))
      s)))
Vars in clojure.core/take-last:
Used in 0 other vars

Comments top

No comments for take-last. Log in to add a comment.