- Clojure - Libraries
- Clojure - Automated Testing
- Clojure - Applications
- Clojure - Concurrent Programming
- Clojure - Java Interface
- Clojure - Databases
- Clojure - Reference Values
- Clojure - Macros
- Clojure - Watchers
- Clojure - Agents
- Clojure - StructMaps
- Clojure - Metadata
- Clojure - Atoms
- Clojure - Date & Time
- Clojure - Destructuring
- Clojure - Predicates
- Clojure - Regular Expressions
- Clojure - Sequences
- Clojure - Exception Handling
- Clojure - Namespaces
- Clojure - Maps
- Clojure - Vectors
- Clojure - Sets
- Clojure - Lists
- Clojure - Strings
- Clojure - File I/O
- Clojure - Recursion
- Clojure - Numbers
- Clojure - Functions
- Clojure - Decision Making
- Clojure - Loops
- Clojure - Operators
- Clojure - Variables
- Clojure - Data Types
- Clojure - REPL
- Clojure - Basic Syntax
- Clojure - Environment
- Clojure - Overview
- Clojure - Home
Clojure Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Clojure - Lists
List is a structure used to store a collection of data items. In Clojure, the List implements the ISeq interface. Lists are created in Clojure by using the pst function.
Example
Following is an example of creating a pst of numbers in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (println (pst 1 2 3 4))) (example)
Output
The above code produces the following output.
(1 2 3 4)
Following is an example of creating a pst of characters in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (println (pst a b c d))) (example)
The above code produces the following output.
(a b c d)
Following are the pst methods available in Clojure.
Sr.No. | Lists & Description |
---|---|
1 | Creates a new pst containing the items prepended to the rest, the last of which will be treated as a sequence. |
2 | This function returns the first item in the pst. |
3 | This function returns the item in the ‘nth’ position in the pst. |
4 | Returns a new pst wherein an element is added to the beginning of the pst. |
5 | Returns a new pst wherein the pst is at the beginning and the elements to be appended are placed at the end. |
6 | Returns the remaining items in the pst after the first item. |