encyclopegia.org

Pure function

In computer programming, a pure function is a function that has the following properties: # the function return values are identical for identical arguments (no variation with local static variables, non-local variables, mutable reference arguments or input streams, i.e., referential transparency), and # the function has no side effects (no mutation of non-local variables, mutable reference arguments or input/output streams).

In computer programming, a pure function is a function that has the following properties: the function return values are identical for identical arguments (no variation with local static variables, non-local variables, mutable reference arguments or input streams, i.e., referential transparency), and the function has no side effects (no mutation of non-local variables, mutable reference arguments or input/output streams). static int fact(int n) { return n std::string s = "Hello, world!"; int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int l = 0; for (int i = 0; i can be optimized such that the value of s.length() is computed only once, before the loop. Some programming languages allow for declaring a pure property to a function: In Fortran and D, the pure keyword can be used to declare a function to be just side-effect free (i.e. have just the above property 2). The compiler may be able to deduce property 1 on top of the declaration. See also: . In the GCC, the pure attribute specifies property 2, while the const attribute specifies a truly pure function with both properties. Languages offering compile-time function execution may require functions to be pure, sometimes with the addition of some other constraints. Examples include constexpr of C++ (both properties). See also: .

References

No reference rows published for this article.

Cite this article

MLA

"Pure function." encyclopegia.org, 2026, https://encyclopegia.org/wiki/pure-function. Accessed 24 November 2026.

Chicago

"Pure function." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/pure-function.

APA

encyclopegia.org. (2026). Pure function. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/pure-function

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

A8(M) motorway (Northern Ireland)

enwiki · references available

Patrina loukoumia

enwiki · references available

Hugo O. Engelmann

enwiki · references available

Lou Carcolh

enwiki · references available

Chris Maguire

enwiki · references available

Don't Stop Movin' (S Club 7 song)

enwiki · references available

Ben Gill

enwiki · references available

Southern Tagalog Arterial Road

enwiki · references available

List of European Solheim Cup golfers

enwiki · references available

Surinder Kaur

enwiki · references available

Niyi Osundare

enwiki · references available

Abdel Kader (song)

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1366129273 · 0.5 · snapshot enwiki-001366129273

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.