Clojure – Sequences reverse

Clojure sequences reverse

In this guide, we will discuss Clojure Sequences reverse. Reverses the elements in the sequence.

Syntax

Following is the syntax.

(reverse seq1)

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

Return Value − The reverse sequence of elements is returned.

Example

Following is an example of reverse in Clojure.

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

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

Output

The above program produces the following output.

(3 2 1)

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply