Public Vars
- * (clj)
- *' (clj)
- *1 (clj)
- *2 (clj)
- *3 (clj)
- *clojure-version* (clj)
- *data-readers* (clj)
- *default-data-reader-fn* (clj)
- *e (clj)
- *print-length* (clj)
- *print-level* (clj)
- *print-namespace-maps* (clj)
- *repl* (clj)
- *verbose-defrecords* (clj)
- + (clj)
- +' (clj)
- - (clj)
- -' (clj)
- -> (clj)
- ->> (clj)
- ->ArrayChunk (clj)
- ->Eduction (clj)
- ->Vec (clj)
- ->VecNode (clj)
- ->VecSeq (clj)
- -cache-protocol-fn (clj)
- -reset-methods (clj)
- .. (clj)
- / (clj)
- < (clj)
- <= (clj)
- = (clj)
- == (clj)
- > (clj)
- >= (clj)
- ArrayChunk (clj)
- ArrayManager (clj)
- EMPTY-NODE (clj)
- Eduction (clj)
- IVecImpl (clj)
- Inst (clj)
- NaN? (clj)
- PrintWriter-on (clj)
- StackTraceElement->vec (clj)
- Throwable->map (clj)
- Vec (clj)
- VecNode (clj)
- VecSeq (clj)
- abs (clj)
- accessor (clj)
- aclone (clj)
- add-classpath (clj)
- add-tap (clj)
- add-watch (clj)
- agent (clj)
- agent-error (clj)
- agent-errors (clj)
- aget (clj)
- alength (clj)
- alias (clj)
- all-ns (clj)
- alter (clj)
- alter-meta! (clj)
- alter-var-root (clj)
- amap (clj)
- ancestors (clj)
- and (clj)
- any? (clj)
- apply (clj)
- areduce (clj)
- array (clj)
- array-map (clj)
- arrayFor (clj)
- as-> (clj)
- aset (clj)
- assert (clj)
- assoc (clj)
- assoc! (clj)
- assoc-in (clj)
- associative? (clj)
- atom (clj)
- await (clj)
- await-for (clj)
- await1 (clj)
- bases (clj)
- bean (clj)
- bigdec (clj)
- bigint (clj)
- biginteger (clj)
- binding (clj)
- bit-and (clj)
- bit-and-not (clj)
- bit-clear (clj)
- bit-flip (clj)
- bit-not (clj)
- bit-or (clj)
- bit-set (clj)
- bit-shift-left (clj)
- bit-shift-right (clj)
- bit-test (clj)
- bit-xor (clj)
- boolean (clj)
- boolean-array (clj)
- boolean? (clj)
- bound-fn (clj)
- bound-fn* (clj)
- bound? (clj)
- bounded-count (clj)
- butlast (clj)
- byte (clj)
- byte-array (clj)
- bytes? (clj)
- case (clj)
- cast (clj)
- cat (clj)
- char (clj)
- char-array (clj)
- char-escape-string (clj)
- char-name-string (clj)
- char? (clj)
- chunk (clj)
- chunk-append (clj)
- chunk-buffer (clj)
- chunk-cons (clj)
- chunk-first (clj)
- chunk-next (clj)
- chunk-rest (clj)
- chunked-seq? (clj)
- class (clj)
- class? (clj)
- clear-agent-errors (clj)
- clojure-version (clj)
- coll? (clj)
- comment (clj)
- commute (clj)
- comp (clj)
- comparator (clj)
- compare (clj)
- compare-and-set! (clj)
- compile (clj)
- complement (clj)
- completing (clj)
- concat (clj)
- cond (clj)
- cond-> (clj)
- cond->> (clj)
- condp (clj)
- conj (clj)
- conj! (clj)
- cons (clj)
- constantly (clj)
- construct-proxy (clj)
- contains? (clj)
- count (clj)
- counted? (clj)
- create-ns (clj)
- create-struct (clj)
- cycle (clj)
- dec (clj)
- dec' (clj)
- decimal? (clj)
- declare (clj)
- dedupe (clj)
- default-data-readers (clj)
- definline (clj)
- definterface (clj)
- defmacro (clj)
- defmethod (clj)
- defmulti (clj)
- defn (clj)
- defn- (clj)
- defonce (clj)
- defprotocol (clj)
- defrecord (clj)
- defstruct (clj)
- deftype (clj)
- delay (clj)
- delay? (clj)
- deliver (clj)
- denominator (clj)
- deref (clj)
- derive (clj)
- descendants (clj)
- destructure (clj)
- disj (clj)
- disj! (clj)
- dissoc (clj)
- dissoc! (clj)
- distinct (clj)
- distinct? (clj)
- doAssoc (clj)
- doall (clj)
- dorun (clj)
- doseq (clj)
- dosync (clj)
- dotimes (clj)
- doto (clj)
- double (clj)
- double-array (clj)
- double? (clj)
- drop (clj)
- drop-last (clj)
- drop-while (clj)
- eduction (clj)
- empty (clj)
- empty? (clj)
- ensure (clj)
- ensure-reduced (clj)
- enumeration-seq (clj)
- error-handler (clj)
- error-mode (clj)
- eval (clj)
- even? (clj)
- every-pred (clj)
- every? (clj)
- ex-cause (clj)
- ex-data (clj)
- ex-info (clj)
- ex-message (clj)
- extend (clj)
- extend-protocol (clj)
- extend-type (clj)
- extenders (clj)
- extends? (clj)
- false? (clj)
- ffirst (clj)
- file-seq (clj)
- filter (clj)
- filterv (clj)
- find (clj)
- find-keyword (clj)
- find-ns (clj)
- find-protocol-impl (clj)
- find-protocol-method (clj)
- find-var (clj)
- first (clj)
- flatten (clj)
- float (clj)
- float-array (clj)
- float? (clj)
- flush (clj)
- fn (clj)
- fn? (clj)
- fnext (clj)
- fnil (clj)
- for (clj)
- force (clj)
- format (clj)
- frequencies (clj)
- future (clj)
- future-call (clj)
- future-cancel (clj)
- future-cancelled? (clj)
- future-done? (clj)
- future? (clj)
- gen-class (clj)
- gen-interface (clj)
- gensym (clj)
- get (clj)
- get-in (clj)
- get-method (clj)
- get-proxy-class (clj)
- get-thread-bindings (clj)
- get-validator (clj)
- global-hierarchy (clj)
- group-by (clj)
- halt-when (clj)
- hash (clj)
- hash-combine (clj)
- hash-map (clj)
- hash-ordered-coll (clj)
- hash-set (clj)
- hash-unordered-coll (clj)
- ident? (clj)
- identical? (clj)
- identity (clj)
- if-let (clj)
- if-not (clj)
- if-some (clj)
- ifn? (clj)
- import (clj)
- inc (clj)
- inc' (clj)
- indexed? (clj)
- infinite? (clj)
- init-proxy (clj)
- inst-ms (clj)
- inst-ms* (clj)
- inst? (clj)
- instance? (clj)
- int (clj)
- int-array (clj)
- int? (clj)
- integer? (clj)
- interleave (clj)
- intern (clj)
- interpose (clj)
- into (clj)
- into-array (clj)
- io! (clj)
- isa? (clj)
- iterate (clj)
- iteration (clj)
- iterator-seq (clj)
- juxt (clj)
- keep (clj)
- keep-indexed (clj)
- key (clj)
- keys (clj)
- keyword (clj)
- keyword? (clj)
- last (clj)
- lazy-cat (clj)
- lazy-seq (clj)
- let (clj)
- letfn (clj)
- line-seq (clj)
- list (clj)
- list* (clj)
- list? (clj)
- load (clj)
- load-reader (clj)
- load-string (clj)
- loaded-libs (clj)
- locking (clj)
- long (clj)
- long-array (clj)
- loop (clj)
- macroexpand (clj)
- macroexpand-1 (clj)
- make-array (clj)
- make-hierarchy (clj)
- map (clj)
- map-entry? (clj)
- map-indexed (clj)
- map? (clj)
- mapcat (clj)
- mapv (clj)
- max (clj)
- max-key (clj)
- memfn (clj)
- memoize (clj)
- merge (clj)
- merge-with (clj)
- meta (clj)
- method-sig (clj)
- methods (clj)
- min (clj)
- min-key (clj)
- mix-collection-hash (clj)
- mod (clj)
- munge (clj)
- name (clj)
- namespace (clj)
- namespace-munge (clj)
- nat-int? (clj)
- neg-int? (clj)
- neg? (clj)
- newPath (clj)
- newline (clj)
- next (clj)
- nfirst (clj)
- nil? (clj)
- nnext (clj)
- not (clj)
- not-any? (clj)
- not-empty (clj)
- not-every? (clj)
- not= (clj)
- ns (clj)
- ns-aliases (clj)
- ns-imports (clj)
- ns-interns (clj)
- ns-map (clj)
- ns-name (clj)
- ns-publics (clj)
- ns-refers (clj)
- ns-resolve (clj)
- ns-unalias (clj)
- ns-unmap (clj)
- nth (clj)
- nthnext (clj)
- nthrest (clj)
- num (clj)
- number? (clj)
- numerator (clj)
- object-array (clj)
- odd? (clj)
- or (clj)
- parents (clj)
- parse-boolean (clj)
- parse-double (clj)
- parse-long (clj)
- parse-uuid (clj)
- partial (clj)
- partition (clj)
- partition-all (clj)
- partition-by (clj)
- partitionv (clj)
- partitionv-all (clj)
- pcalls (clj)
- peek (clj)
- persistent! (clj)
- pmap (clj)
- pop (clj)
- pop! (clj)
- pop-thread-bindings (clj)
- popTail (clj)
- pos-int? (clj)
- pos? (clj)
- pr (clj)
- pr-str (clj)
- prefer-method (clj)
- prefers (clj)
- primitives-classnames (clj)
- print (clj)
- print-ctor (clj)
- print-dup (clj)
- print-method (clj)
- print-simple (clj)
- print-str (clj)
- printf (clj)
- println (clj)
- println-str (clj)
- prn (clj)
- prn-str (clj)
- process-annotation (clj)
- promise (clj)
- proxy (clj)
- proxy-call-with-super (clj)
- proxy-mappings (clj)
- proxy-name (clj)
- proxy-super (clj)
- push-thread-bindings (clj)
- pushTail (clj)
- pvalues (clj)
- qualified-ident? (clj)
- qualified-keyword? (clj)
- qualified-symbol? (clj)
- quot (clj)
- rand (clj)
- rand-int (clj)
- rand-nth (clj)
- random-sample (clj)
- random-uuid (clj)
- range (clj)
- ratio? (clj)
- rational? (clj)
- rationalize (clj)
- re-find (clj)
- re-groups (clj)
- re-matcher (clj)
- re-matches (clj)
- re-pattern (clj)
- re-seq (clj)
- read (clj)
- read+string (clj)
- read-line (clj)
- read-string (clj)
- reader-conditional (clj)
- reader-conditional? (clj)
- realized? (clj)
- record? (clj)
- reduce (clj)
- reduce-kv (clj)
- reduced (clj)
- reduced? (clj)
- reductions (clj)
- ref (clj)
- ref-history-count (clj)
- ref-max-history (clj)
- ref-min-history (clj)
- ref-set (clj)
- refer (clj)
- refer-clojure (clj)
- reify (clj)
- release-pending-sends (clj)
- rem (clj)
- remove (clj)
- remove-all-methods (clj)
- remove-method (clj)
- remove-ns (clj)
- remove-tap (clj)
- remove-watch (clj)
- repeat (clj)
- repeatedly (clj)
- replace (clj)
- replicate (clj)
- require (clj)
- requiring-resolve (clj)
- reset! (clj)
- reset-meta! (clj)
- reset-vals! (clj)
- resolve (clj)
- rest (clj)
- restart-agent (clj)
- resultset-seq (clj)
- reverse (clj)
- reversible? (clj)
- rseq (clj)
- rsubseq (clj)
- run! (clj)
- satisfies? (clj)
- second (clj)
- select-keys (clj)
- send (clj)
- send-off (clj)
- send-via (clj)
- seq (clj)
- seq-to-map-for-destructuring (clj)
- seq? (clj)
- seqable? (clj)
- seque (clj)
- sequence (clj)
- sequential? (clj)
- set (clj)
- set-agent-send-executor! (clj)
- set-agent-send-off-executor! (clj)
- set-error-handler! (clj)
- set-error-mode! (clj)
- set-validator! (clj)
- set? (clj)
- short (clj)
- short-array (clj)
- shuffle (clj)
- shutdown-agents (clj)
- simple-ident? (clj)
- simple-keyword? (clj)
- simple-symbol? (clj)
- slurp (clj)
- some (clj)
- some-> (clj)
- some->> (clj)
- some-fn (clj)
- some? (clj)
- sort (clj)
- sort-by (clj)
- sorted-map (clj)
- sorted-map-by (clj)
- sorted-set (clj)
- sorted-set-by (clj)
- sorted? (clj)
- special-symbol? (clj)
- spit (clj)
- split-at (clj)
- split-with (clj)
- splitv-at (clj)
- str (clj)
- string? (clj)
- struct (clj)
- struct-map (clj)
- subs (clj)
- subseq (clj)
- subvec (clj)
- supers (clj)
- swap! (clj)
- swap-vals! (clj)
- symbol (clj)
- symbol? (clj)
- sync (clj)
- tagged-literal (clj)
- tagged-literal? (clj)
- tailoff (clj)
- take (clj)
- take-last (clj)
- take-nth (clj)
- take-while (clj)
- tap> (clj)
- test (clj)
- the-ns (clj)
- thread-bound? (clj)
- time (clj)
- to-array (clj)
- to-array-2d (clj)
- trampoline (clj)
- transduce (clj)
- transient (clj)
- tree-seq (clj)
- true? (clj)
- type (clj)
- unchecked-add (clj)
- unchecked-add-int (clj)
- unchecked-byte (clj)
- unchecked-char (clj)
- unchecked-dec (clj)
- unchecked-dec-int (clj)
- unchecked-divide-int (clj)
- unchecked-double (clj)
- unchecked-float (clj)
- unchecked-inc (clj)
- unchecked-inc-int (clj)
- unchecked-int (clj)
- unchecked-long (clj)
- unchecked-multiply (clj)
- unchecked-multiply-int (clj)
- unchecked-negate (clj)
- unchecked-negate-int (clj)
- unchecked-remainder-int (clj)
- unchecked-short (clj)
- unchecked-subtract (clj)
- unchecked-subtract-int (clj)
- underive (clj)
- unquote (clj)
- unquote-splicing (clj)
- unreduced (clj)
- unsigned-bit-shift-right (clj)
- update (clj)
- update-in (clj)
- update-keys (clj)
- update-proxy (clj)
- update-vals (clj)
- uri? (clj)
- use (clj)
- uuid? (clj)
- val (clj)
- vals (clj)
- var-get (clj)
- var-set (clj)
- var? (clj)
- vary-meta (clj)
- vec (clj)
- vector (clj)
- vector-of (clj)
- vector? (clj)
- volatile! (clj)
- volatile? (clj)
- vreset! (clj)
- vswap! (clj)
- when (clj)
- when-first (clj)
- when-let (clj)
- when-not (clj)
- when-some (clj)
- while (clj)
- with-bindings (clj)
- with-bindings* (clj)
- with-in-str (clj)
- with-loading-context (clj)
- with-local-vars (clj)
- with-meta (clj)
- with-open (clj)
- with-out-str (clj)
- with-precision (clj)
- with-redefs (clj)
- with-redefs-fn (clj)
- xml-seq (clj)
- zero? (clj)
- zipmap (clj)
Back
require (clj)
(source)function
(require & args)
Loads libs, skipping any that are already loaded. Each argument is
either a libspec that identifies a lib, a prefix list that identifies
multiple libs whose names share a common prefix, or a flag that modifies
how all the identified libs are loaded. Use :require in the ns macro
in preference to calling this directly.
Libs
A 'lib' is a named set of resources in classpath whose contents define a
library of Clojure code. Lib names are symbols and each lib is associated
with a Clojure namespace and a Java package that share its name. A lib's
name also locates its root directory within classpath using Java's
package name to classpath-relative path mapping. All resources in a lib
should be contained in the directory structure under its root directory.
All definitions a lib makes should be in its associated namespace.
'require loads a lib by loading its root resource. The root resource path
is derived from the lib name in the following manner:
Consider a lib named by the symbol 'x.y.z; it has the root directory
<classpath>/x/y/, and its root resource is <classpath>/x/y/z.clj, or
<classpath>/x/y/z.cljc if <classpath>/x/y/z.clj does not exist. The
root resource should contain code to create the lib's
namespace (usually by using the ns macro) and load any additional
lib resources.
Libspecs
A libspec is a lib name or a vector containing a lib name followed by
options expressed as sequential keywords and arguments.
Recognized options:
:as takes a symbol as its argument and makes that symbol an alias to the
lib's namespace in the current namespace.
:as-alias takes a symbol as its argument and aliases like :as, however
the lib will not be loaded. If the lib has not been loaded, a new
empty namespace will be created (as with create-ns).
:refer takes a list of symbols to refer from the namespace or the :all
keyword to bring in all public vars.
Prefix Lists
It's common for Clojure code to depend on several libs whose names have
the same prefix. When specifying libs, prefix lists can be used to reduce
repetition. A prefix list contains the shared prefix followed by libspecs
with the shared prefix removed from the lib names. After removing the
prefix, the names that remain must not contain any periods.
Flags
A flag is a keyword.
Recognized flags: :reload, :reload-all, :verbose
:reload forces loading of all the identified libs even if they are
already loaded (has no effect on libspecs using :as-alias)
:reload-all implies :reload and also forces loading of all libs that the
identified libs directly or indirectly load via require or use
(has no effect on libspecs using :as-alias)
:verbose triggers printing information about each load, alias, and refer
Example:
The following would load the libraries clojure.zip and clojure.set
abbreviated as 's'.
(require '(clojure zip [set :as s]))
Examples
clojure
(ns clojure.test-clojure.server
(:import java.util.Random)
(:require [clojure.test :refer :all])
(:require [clojure.core.server :as s]))
(deftest test-validate-opts
(check-invalid-opts {} "Missing required socket server property :name")
(check-invalid-opts {:name "a" :accept 'clojure.core/+} "Missing required socket server property :port")
(doseq [port [-1 "5" 999999]]
(check-invalid-opts {:name "a" :port port :accept 'clojure.core/+} (str "Invalid socket server port: " port)))
(check-invalid-opts {:name "a" :port 5555} "Missing required socket server property :accept"))
clojure
(deftest division
(is (= clojure.core// /))
(binding [*ns* *ns*]
(eval '(do (ns foo
(:require [clojure.core :as bar])
(:use [clojure.test]))
(is (= clojure.core// bar//))))))
(require '[clojure.string :as s])
(deftest namespaced-maps
(is (= #:a{1 nil, :b nil, :b/c nil, :_/d nil}
#:a {1 nil, :b nil, :b/c nil, :_/d nil}
{1 nil, :a/b nil, :b/c nil, :d nil}))
(is (= #::{1 nil, :a nil, :a/b nil, :_/d nil}
#:: {1 nil, :a nil, :a/b nil, :_/d nil}
{1 nil, :clojure.test-clojure.reader/a nil, :a/b nil, :d nil} ))
(is (= #::s{1 nil, :a nil, :a/b nil, :_/d nil}
#::s {1 nil, :a nil, :a/b nil, :_/d nil}
{1 nil, :clojure.string/a nil, :a/b nil, :d nil}))
(is (= (read-string "#:a{b 1 b/c 2}") {'a/b 1, 'b/c 2}))
(is (= (binding [*ns* (the-ns 'clojure.test-clojure.reader)] (read-string "#::{b 1, b/c 2, _/d 3}")) {'clojure.test-clojure.reader/b 1, 'b/c 2, 'd 3}))
(is (= (binding [*ns* (the-ns 'clojure.test-clojure.reader)] (read-string "#::s{b 1, b/c 2, _/d 3}")) {'clojure.string/b 1, 'b/c 2, 'd 3})))
clojure/core.async
;; The clojure.core.async namespace contains the public API.
(require '[clojure.core.async :as async :refer :all])
;; Data is transmitted on queue-like channels. By default channels
;; are unbuffered (0-length) - they require producer and consumer to
;; rendezvous for the transfer of a value through the channel.