Clojure - Sequences drop

Drops elements from a sequence based on the number of elements, which needs to be removed.


Following is the syntax.

(drop num seq1)

Parameters − ‘seq1’ is the sequence list of elements. ‘num’ is the number of elements which need to be dropped.

Return Value − Returns the sequence of elements with the required elements dropped from the sequence.


Following is an example of drop in Clojure.

(ns clojure.examples.example

;; This program displays Hello World
(defn Example []
   (def seq1 (seq [5 4 3 2 1]))
   (def seq2 (drop 2 seq1))
   (println seq2))


The above program produces the following output.

(3 2 1)
Kickstart Your Career

Get certified by completing the course

Get Started