Computer Dictionary Online

Medical Dictionary   Law Dictionary   Legal Dictionary   Website Design

0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z 

Church integer

A representation of integers as functions invented by Alonzo Church, inventor of lambda-calculus. The integer N is represented as a higher-order function which applies a given function N times to a given expression. In the pure lambda-calculus there are no constants but numbers can be represented by Church integers.

A Haskell function to return a given Church integer could be written:

		church n = c
			   c f x = if n == 0 then x else c' f (f x)
				   c' = church (n-1)

A function to turn a Church integer into an ordinary integer:

		unchurch c = c (+1) 0

See also von Neumann integer.


Contact the Computer Dictionary Online  ::  Link to the Computer Dictionary Online  ::  Disclaimer for Computer Dictionary Online

Computer Dictionary Online
Copyright © 2018