Clojure Tutorial
Clojure Useful Resources
Selected Reading
- 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 - Sets
Clojure - Sets
Sets in Clojure are a set of unique values. Sets are created in Clojure with the help of the set command.
Example
Following is an example of the creation of sets in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (println (set (1 1 2 2)))) (example)
Output
The above code produces the following output.
#{1,2}
Following are the methods available in Clojure for sets.
Sr.No. | Sets & Description |
---|---|
1 | Returns a sorted set of elements. |
2 | Returns the element at the index position. |
3 | Finds out whether the set contains a certain element or not. |
4 | Appends an element to the set and returns the new set of elements. |
5 | Disjoins an element from the set. |
6 | Return a set that is the union of the input sets |
7 | Return a set that is the first set without elements of the remaining sets. |
8 | Return a set that is the intersection of the input sets. |
9 | Is set1 a subset of set2? |
10 | Is set1 a superset of set2? |