
- Clojure Tutorial
- Clojure - Home
- Clojure - Overview
- Clojure - Environment
- Clojure - Basic Syntax
- Clojure - REPL
- Clojure - Data Types
- Clojure - Variables
- Clojure - Operators
- Clojure - Loops
- Clojure - Decision Making
- Clojure - Functions
- Clojure - Numbers
- Clojure - Recursion
- Clojure - File I/O
- Clojure - Strings
- Clojure - Lists
- Clojure - Sets
- Clojure - Vectors
- Clojure - Maps
- Clojure - Namespaces
- Clojure - Exception Handling
- Clojure - Sequences
- Clojure - Regular Expressions
- Clojure - Predicates
- Clojure - Destructuring
- Clojure - Date & Time
- Clojure - Atoms
- Clojure - Metadata
- Clojure - StructMaps
- Clojure - Agents
- Clojure - Watchers
- Clojure - Macros
- Clojure - Reference Values
- Clojure - Databases
- Clojure - Java Interface
- Clojure - Concurrent Programming
- Clojure - Applications
- Clojure - Automated Testing
- Clojure - Libraries
- Clojure Useful Resources
- Clojure - Quick Guide
- Clojure - Useful Resources
- Clojure - Discussion
Clojure - Sequences conj
Returns a new sequence where ‘x’ is the element that is added to the end of the sequence.
Syntax
Following is the syntax.
(conj seq x)
Parameters − ‘x’ is the element which needs to be added to the sequence. ‘seq’ is the sequence list of elements.
Return Value − The new sequence with the appended element.
Example
Following is an example of conj in Clojure. Note that in the following program, we are also seeing the shorter version of creating a sequence, which can simply be done by using the square brackets [].
(ns clojure.examples.example (:gen-class)) ;; This program displays Hello World (defn Example [] (println (conj [1 2 3] 4))) (Example)
Output
The above program produces the following output.
(1 2 3 4)
clojure_sequences.htm
Advertisements