Clojure – Sequences last

Clojure sequences last

In this guide, we will discuss Clojure Sequences last. Returns the last element of the sequence.

Syntax

Following is the syntax.

(last seq1)

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

Return Value − The last element of the sequence is returned.

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]))
   (println (last seq1)))
(Example)

Output

The above program produces the following output.

3

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply