A list is a data storage structure that holds a collection of data objects. The list
method in Clojure builds lists.
The list method in Clojure creates lists by appending data items to a list and sequencing the list’s last data.
(list* listitems [lst])
From the syntax above, there are basically two parameters passed to a list
method:
listitems
: These are data items we want to add to a list.lst
: This is the list to which we will add data items.
Let’s see an example(ns clojure.listt.listt(:gen-class))(defn listt [](println (list* 1 [5,9])))(listt)
Line 3: We define a function, list
.
Line 4: We print the list items of the newly created list using println
. We then create a list using the list*
method.
Line 5: We call the list
function.