or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

concurrency.mdcontrol-flow.mdcore-language.mddata-structures.mddata-utilities.mddev-tools.mdformats.mdindex.mdio.mdjava-interop.mdmath.mdsequences.mdstrings.mdtesting.md
tile.json

tessl/maven-org-clojure--clojure

Clojure core environment and runtime library providing a dynamic, general-purpose programming language on the JVM.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.clojure/clojure@1.12.x

To install, run

npx @tessl/cli install tessl/maven-org-clojure--clojure@1.12.0

index.mddocs/

Clojure

Clojure is a dynamic, general-purpose programming language that combines the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. This package contains the core Clojure runtime environment and standard library, providing a modern Lisp dialect that runs on the Java Virtual Machine (JVM). It features immutable data structures, a powerful macro system, functional programming paradigms, seamless Java interoperability, and built-in support for concurrent programming through software transactional memory, agents, and atoms.

Package Information

  • Package Name: org.clojure:clojure
  • Package Type: maven
  • Language: Clojure/Java
  • Installation: Add to Maven pom.xml:
<dependency>
    <groupId>org.clojure</groupId>
    <artifactId>clojure</artifactId>
    <version>1.12.0</version>
</dependency>

For Leiningen:

[org.clojure/clojure "1.12.0"]

Core Imports

(ns your.namespace
  (:require [clojure.string :as str]
            [clojure.set :as set] 
            [clojure.walk :as walk]
            [clojure.java.io :as io]
            [clojure.math :as math]
            [clojure.edn :as edn]
            [clojure.zip :as zip]
            [clojure.datafy :as datafy]
            [clojure.stacktrace :as st]
            [clojure.inspector :as inspect]))

The clojure.core namespace is automatically available in all Clojure code.

Basic Usage

;; Data structures are immutable by default
(def data {:name "Alice" :age 30 :languages ["Clojure" "Java"]})

;; Functional programming with collections
(def numbers [1 2 3 4 5])
(def doubled (map #(* 2 %) numbers))
(def evens (filter even? numbers))

;; Working with maps
(def updated-data (assoc data :email "alice@example.com"))
(def name (get data :name))

;; Concurrency with atoms
(def counter (atom 0))
(swap! counter inc)
@counter ; => 1

;; List comprehension equivalent
(for [x (range 10)
      :when (even? x)]
  (* x x))

Architecture

Clojure is built around several key design principles:

  • Immutable Data Structures: All core data structures (lists, vectors, maps, sets) are immutable by default
  • Functional Programming: First-class functions, higher-order functions, and emphasis on pure functions
  • Lisp Syntax: Homoiconic syntax where code is data, enabling powerful macro systems
  • JVM Integration: Seamless interoperability with Java libraries and the JVM ecosystem
  • Concurrency Primitives: Built-in support for concurrent programming through STM, agents, and atoms
  • Lazy Evaluation: Lazy sequences for efficient handling of large or infinite data sets

Capabilities

Core Language Features

Fundamental language constructs including data structures, control flow, functions, and macros that form the foundation of Clojure programming.

;; Data structure constructors
(list & items) ; => Creates a list
(vector & args) ; => Creates a vector  
(hash-map & keyvals) ; => Creates a hash map
(hash-set & keys) ; => Creates a hash set

;; Core sequence operations
(first coll) ; => First item in collection
(rest coll) ; => All but first item
(cons x seq) ; => New sequence with x prepended
(conj coll & xs) ; => Add items to collection

Core Language Features

Sequence Operations

Comprehensive collection processing functions for transforming, filtering, and manipulating sequences with lazy evaluation.

(map f & colls) ; => Apply function to each element
(filter pred coll) ; => Lazy sequence of items where pred is true
(reduce f coll) ; => Reduce collection using function
(take n coll) ; => First n items
(drop n coll) ; => All but first n items

Sequence Operations

Data Structures and Collections

Immutable, persistent data structures including vectors, maps, sets, and their manipulation functions.

;; Map operations
(get map key) ; => Value for key
(assoc map key val & kvs) ; => New map with associations
(dissoc map & keys) ; => New map without keys
(update m k f & args) ; => Update value at key using function

;; Collection predicates
(vector? x) ; => True if x is a vector
(map? x) ; => True if x is a map
(seq? x) ; => True if x is a sequence

Data Structures

Concurrency and State Management

Safe concurrent programming with atoms, refs, agents, and software transactional memory.

;; Atoms for synchronous updates
(atom x & opts) ; => Create atomic reference
(swap! atom f & args) ; => Atomically update using function
(reset! atom newval) ; => Set new value

;; Refs for coordinated updates  
(ref x & opts) ; => Create transactional reference
(dosync & exprs) ; => Execute in transaction

Concurrency

String Processing

Comprehensive string manipulation utilities through the clojure.string namespace.

(clojure.string/join separator coll) ; => Join collection with separator
(clojure.string/split s regex) ; => Split string on regex
(clojure.string/replace s match replacement) ; => Replace all matches
(clojure.string/trim s) ; => Remove leading/trailing whitespace

String Processing

Control Flow and Macros

Advanced control structures, conditional execution, and macro system for metaprogramming.

;; Conditional macros
(when test & then) ; => Execute when test is true
(if-not test then else) ; => Inverted conditional
(cond & clauses) ; => Multi-branch conditional

;; Macro definition
(defmacro name doc-string? attr-map? [params*] body)

Control Flow and Macros

Java Interoperability

Seamless integration with Java classes, methods, and the broader JVM ecosystem.

;; Java interop syntax
(.method object args*) ; => Call instance method
(ClassName/staticMethod args*) ; => Call static method
(new ClassName args*) ; => Create new instance
(import 'java.util.Date) ; => Import Java class

Java Interop

I/O and File Operations

File system operations, stream processing, and I/O utilities through clojure.java.io.

(slurp f & opts) ; => Read entire file as string
(spit f content & opts) ; => Write content to file  
(clojure.java.io/reader source) ; => Create BufferedReader
(clojure.java.io/writer dest) ; => Create BufferedWriter

I/O Operations

Mathematical Functions

Comprehensive mathematical functions and constants through the clojure.math namespace.

;; Mathematical constants
clojure.math/E    ; => Euler's number e
clojure.math/PI   ; => Pi constant

;; Trigonometric functions
(clojure.math/sin a) ; => Sine of angle in radians
(clojure.math/cos a) ; => Cosine of angle in radians
(clojure.math/tan a) ; => Tangent of angle in radians

;; Exponential and logarithmic
(clojure.math/exp a) ; => e raised to power a
(clojure.math/log a) ; => Natural logarithm of a
(clojure.math/pow a b) ; => a raised to power b

Mathematical Functions

Data Structure Utilities

Generic tree traversal, functional zippers, and data transformation utilities.

;; Tree walking (clojure.walk)
(clojure.walk/postwalk f form) ; => Post-order traversal
(clojure.walk/prewalk f form) ; => Pre-order traversal
(clojure.walk/keywordize-keys m) ; => String keys to keywords

;; Functional zippers (clojure.zip)  
(clojure.zip/vector-zip root) ; => Zipper for nested vectors
(clojure.zip/down loc) ; => Navigate to first child
(clojure.zip/edit loc f & args) ; => Edit node at location

;; Data transformation (clojure.datafy)
(clojure.datafy/datafy x) ; => Transform object to data

Data Structure Utilities

Data Format Processing

Utilities for EDN parsing, UUID handling, and XML processing.

;; EDN format (clojure.edn)
(clojure.edn/read-string s) ; => Parse EDN string
(clojure.edn/read stream) ; => Read EDN from stream

;; UUID support (clojure.uuid)
#uuid "550e8400-e29b-41d4-a716-446655440000" ; => UUID literal

;; XML processing (clojure.xml)
(clojure.xml/parse source) ; => Parse XML to nested maps
(clojure.xml/emit element) ; => Emit XML from data

Data Format Processing

Development Tools

Debugging, inspection, and code generation utilities.

;; Stack trace analysis (clojure.stacktrace)
(clojure.stacktrace/print-cause-trace t) ; => Print exception chain
(clojure.stacktrace/root-cause t) ; => Get root cause exception

;; Data inspection (clojure.inspector)  
(clojure.inspector/inspect data) ; => Graphical data inspector
(clojure.inspector/inspect-tree data) ; => Tree view inspector

;; Code templates (clojure.template)
(clojure.template/do-template argv expr & values) ; => Generate repetitive code

Development Tools

Testing Framework

Comprehensive unit testing framework through clojure.test namespace.

(deftest name & body) ; => Define test function
(is form) ; => Assert that form is true
(testing string & body) ; => Group assertions with description
(run-tests & namespaces) ; => Execute tests

Testing

Types

;; Core data types (all immutable)
java.lang.Object ; Base type for all Clojure values
clojure.lang.IPersistentList ; List interface
clojure.lang.IPersistentVector ; Vector interface  
clojure.lang.IPersistentMap ; Map interface
clojure.lang.IPersistentSet ; Set interface
clojure.lang.ISeq ; Sequence interface
clojure.lang.Keyword ; Keyword type
clojure.lang.Symbol ; Symbol type

;; Reference types for concurrency
clojure.lang.Atom ; Atomic reference
clojure.lang.Ref ; Transactional reference
clojure.lang.Agent ; Asynchronous reference
clojure.lang.Var ; Variable binding

;; Function types
clojure.lang.IFn ; Function interface
clojure.lang.MultiFn ; Multimethod