Rex (language)
Encyclopedia
rex is a functional programming language developed by Robert M. Keller for use in teaching functional programming to Harvey Mudd College
Harvey Mudd College
Harvey Mudd College is a private residential liberal arts college of science, engineering, and mathematics, located in Claremont, California. It is one of the institutions of the contiguous Claremont Colleges, which share adjoining campus grounds....

 students. The rex interpreter is written in Prolog
Prolog
Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is declarative: the program logic is expressed in terms of...

.

Example

The "Hello World"
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

 of functional languages is the factorial
Factorial
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n...

function. Expressed in rex:

factorial(0) => 1;
factorial(X) => X * factorial(X-1);

The name "rex" derives from "rewriting expressions", which is the basic principle underlying the implementation: replace an instantation of an expression on the left-hand side of a rule with the instantiated right-hand side.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK