
- 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 - contains?
Finds out whether the set contains a certain element or not.
Syntax
Following is the syntax.
(contains? setofelements searchelement)
Parameters − setofelements is the set of elements. Searchelement is the element which needs to be searched for in the list.
Return Value − Returns true if the element exists in the set or false if it dosent.
Example
Following is an example of contains? in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (println (contains? (set '(3 2 1)) 2)) (println (contains? (set '(3 2 1)) 5))) (example)
Output
The above code produces the following output.
true false
clojure_sets.htm
Advertisements