- 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 - Sequences
Sequences are created with the help of the ‘seq’ command. Following is a simple example of a sequence creation.
(ns clojure.examples.example (:gen-class)) ;; This program displays Hello World (defn Example [] (println (seq [1 2 3]))) (Example)
The above program produces the following output.
(1 2 3)
Following are the various methods available for sequences.
Sr.No. | Methods & Description |
---|---|
1 | Returns a new sequence where ‘x’ is the first element and ‘seq’ is the rest. |
2 | Returns a new sequence where ‘x’ is the element that is added to the end of the sequence. |
3 | This is used to concat two sequences together. |
4 | Used to only ensure that distinct elements are added to the sequence. |
5 | Reverses the elements in the sequence. |
6 | Returns the first element of the sequence. |
7 | Returns the last element of the sequence. |
8 | Returns the entire sequence except for the first element. |
9 | Returns a sorted sequence of elements. |
10 | Drops elements from a sequence based on the number of elements, which needs to be removed. |
11 | Takes the last pst of elements from the sequence. |
12 | Takes the first pst of elements from the sequence. |
13 | Sppts the sequence of items into two parts. A location is specified at which the sppt should happen. |