Clojure - Sequences rest


Advertisements

Returns the entire sequence except for the first element.

Syntax

Following is the syntax.

(rest seq1)

Parameters − ‘seq1’ is the sequence list of elements.

Return Value − Returns the entire sequence except for the first element.

Example

Following is an example of last in Clojure.

(ns clojure.examples.example
   (:gen-class))

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

Output

The above program produces the following output.

(2 3 4 5)
clojure_sequences.htm
Advertisements