You're viewing version 1.2.0 of drop-last. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

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:2183 top

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

Comments top

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