Skip to content

clojure.core/inc

View this page on ClojureDocs

Type: function Added: Clojure 1.2 Examples: 4 Runnable: 2
([x])

Returns a number one greater than num. Does not auto-promote longs, will throw on overflow. See also: inc'

Examples

by zk on
by ibercode on
by wuleicanada on . May have evaluation errors.
by Crowbrammer on . May have evaluation errors.

Note by icefox

Is the documentation suppose to be: "Returns a number one greater than x." ? If not what is num?

Note by arashgithub

is code "(def i (inc i))" is conflict with the notion of immutable of data in Clojure.

Note by reborg

Nope, quite the opposite. "def" defines a var:

user=> (type (def i 1))
clojure.lang.Var

A var is one of the 4 types dealing with mutable state (it is not an immutable data structure, like maps, vectors, sets and so on) and it does so following a specific semantic (see http://clojure.org/reference/vars).

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.