KRC (Kent Recursive Calculator)

From Bauman National Library
This page was last modified on 21 May 2016, at 21:41.
Kent Recursive Calculator
Paradigm functional
Designed by David Turner
First appeared 1981
Website {{#property:P856}}
Influenced by

Kent Recursive Calculator(KRC) - lazy (call-by-need) functional programming language based on higher order recursion equations.


KRC was developed in 1981 by David Turner based on another functional language named SASL he developed. In 1985 david Turner create another functional language named Miranda based on KRC.

KRC was create for learning. Turner in his book "Functional Programming and Its Applications" explains why he does not use LISP:

Semantics of LISP are rather complicated and include a number of features which would in no sense be regarded as functional.


During the period from 1982 to the time of creating Miranda language in 1985, KPC was used for functional programming learning in University of Kent at Canterbury in UK.


Program (Turner called it script) is a set of equations, giving mathematical defenitions of various entities. KRC functions notation is much more like mathematical than notations in other functional languages.

KRC works with 4 types

  1. number,
  2. string,
  3. list (including an infinite),
  4. function.


  • Lazy evaluation - strategy which delays the evaluation untill its result is needed.
  • Guard expressions - boolean conditional to check a variants of calculations.
  • Pattern metching - comparison with exact value or string or predicate or data type or any supported languages construction.
  • ZF-expresiion (list comprehensions) - a compact description lists operations, including infinite lists.
  • Interactivity: built-in commands for editing scripts, save them and loading from file.
  • A set of library functions for working with lists (map, filter, invert, rotate, swap etc.)



Elements write in square brackets. List can be created by several ways:

  • enumeration
  • concatenation
0: [1,2]
  • as interval from a to b
  • as infinite list


Function name writes on the left from parameters.

Example: squaring function
 sq n = n*n 


Calculating variable`s value

r = u/v
u = x+1
v = 11
x = 23

Order of equations doesn`t matter cause KRC is lazy language and the result of any equation wouldn`t be calculated until not needed.
Command to get value of r:


Prime numbers calculating

primes = sieve [2..]
sieve (p:x) = p:sieve {n; n <- x; n%p > 0}

Request to output numbers:


Prime numbers will be printed indefinitely (or rather until it runs out of space)

[2, 3, 5, 7, 11, 13, 17


  • Writed by Turner on BCPL language - structured language developed in Universyty of Cambridge in 1966 and influenced the B and C languages. This version is designed for EMAS.
  • Writed by Simon J. Croft's later on C under Unix.


  1. J. Darlington,P. Henderson,D. A. Turner : Functional Programming and Its Applications: An Advanced Course
  2. D. A. Turner : The semantic elegance of Applicative Languages