drop-last

clojure.core

  • (drop-last s)
  • (drop-last n s)
Return a lazy sequence of all but the last n (default 1) items in coll

1 Example top

  • user=> (drop-last [1 2 3 4])
    (1 2 3) 
    
    user=> (drop-last -1 [1 2 3 4])
    (1 2 3 4) 
    
    user=> (drop-last 0 [1 2 3 4])
    (1 2 3 4) 
    
    user=> (drop-last 2 [1 2 3 4])
    (1 2)
    
    user=> (drop-last 5 [1 2 3 4])
    ()
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:2525 top

(defn drop-last
  "Return a lazy sequence of all but the last n (default 1) items in coll"
  {:added "1.0"
   :static true}
  ([s] (drop-last 1 s))
  ([n s] (map (fn [x _] x) s (drop n s))))
Vars in clojure.core/drop-last:
Used in 0 other vars

Comments top

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