A list is a data storage structure that holds a collection of data objects. The list method in Clojure is used to build lists.
rest
list method in Clojure?The rest
method is a list method that returns all the items in a list except the first element.
(rest lst)
The rest
method receives a list represented by lst
in the syntax.
The rest
method returns the list of items without the first item of the passed list. Let's see an example to understand this further.
(ns clojure.examples.example(:gen-class))(defn restlist [](println (rest (list 1 2,40,80,12,34))))(restlist)
In the code above:
restlist
. rest
method using the println
, and pass a list of items to the rest
method.restlist
.